Exemplo n.º 1
0
def summary(request, **kwargs): ## startyear=2009, startmonth=1, startday=1, endyear=2009, endmonth=1, endday=1, dst=-1):
    ## returns total and by-day statistics for

    stats = []
    nscu = study.non_stop_consenting_users()
    stats.append(('total users', User.objects.all().count()))
    stats.append(('total consenting users',len(nscu)))
    stats.append(('total notes',Note.objects.all().count()))    
    stats.append(('total notes (from consenting users)',Note.objects.filter(owner__in=nscu).count()))

    #print "users who have not synced"
    #stats.append(('total users who have not synced', len(study.users_with_less_than_n_notes(0,User.objects.all()))))
    stats.append(('total consenting users who have not synced', len(study.users_with_less_than_n_notes(0,nscu))))
    serial_stats(stats)

    for (k,v) in kwargs.iteritems():
        kwargs[k] = int(v)

    if not kwargs.has_key("endyear"):
        end_secs = time.mktime(time.localtime())
    else:
        end_secs = time.mktime( (kwargs['endyear'],kwargs['endmonth'],kwargs['endday'],00,00,00,00,00,kwargs.get('dst',-1)))

    start_secs = time.mktime( (kwargs['startyear'],kwargs['startmonth'],kwargs['startday'],00,00,00,00,00,kwargs.get('dst',-1)))

    stats.append( ('duration', "%s - %s " % (time.ctime(start_secs), time.ctime(end_secs))))
    #stats.append( ('start time msecs' , int(start_secs*1000) ) )
    #stats.append( ('end time msecs', int(end_secs*1000) ))    

    #stats.append(('users active during time', len(study.users_active_during(start_secs,end_secs))))
    stats.append(('total notes created during time',len(study.notes_by_users_created_between(start_secs,end_secs,users=User.objects.all()))))
    stats.append(('total notes modified during time',len(study.notes_by_users_edited_between(start_secs,end_secs,users=User.objects.all()))))
    response = HttpResponse(serial_stats(stats), "text/plain")
    response.status_code = 200;
    return response;
Exemplo n.º 2
0
def random_notes(n=1000,consenting=True,english_only=True,user_filter=is_sigscroll_user):
    from jv3.study.content_analysis import _actlogs_to_values,_notes_to_values,_note_instance_to_value
    
    if consenting:
        users = [ u for u in non_stop_consenting_users() if user_filter(u) ]
    else:
        users = [ u for u in non_stop_users() if user_filter(u) ]
        
    notes = filter_notes(Note.objects.filter(owner__in=users))
    random.shuffle(notes)
    notes = notes[:n]
    print "returning %d notes " % len(notes)
    values = [_note_instance_to_value(v) for v in notes]
    random.shuffle(values)
    return values
Exemplo n.º 3
0
def random_notes(n=1000,
                 consenting=True,
                 english_only=True,
                 user_filter=is_sigscroll_user):
    from jv3.study.content_analysis import _actlogs_to_values, _notes_to_values, _note_instance_to_value

    if consenting:
        users = [u for u in non_stop_consenting_users() if user_filter(u)]
    else:
        users = [u for u in non_stop_users() if user_filter(u)]

    notes = filter_notes(Note.objects.filter(owner__in=users))
    random.shuffle(notes)
    notes = notes[:n]
    print "returning %d notes " % len(notes)
    values = [_note_instance_to_value(v) for v in notes]
    random.shuffle(values)
    return values
Exemplo n.º 4
0
def random_notes_slow(n=1000, consenting=True):
    """ returns random subset of notes """
    if consenting:
        users = non_stop_consenting_users()
    else:
        users = non_stop_users()

    results = []
    keys = []
    notes = Note.objects.filter(owner__in=users)
    i = 0
    while len(results) < n and i < n + 10000:
        note = notes[random.randint(0, notes.count() - 1)]
        if note.id not in keys:
            keys.append(note.id)
            results.append(note)
        i = i + 1
        print "%d " % len(results)
    return results
Exemplo n.º 5
0
def random_notes_slow(n=1000, consenting=True):
    """ returns random subset of notes """
    if consenting:
        users = non_stop_consenting_users()
    else:
        users = non_stop_users()

    results = []
    keys = []
    notes = Note.objects.filter(owner__in=users)
    i = 0
    while len(results) < n and i < n + 10000:
        note = notes[random.randint(0, notes.count() - 1)]
        if note.id not in keys:
            keys.append(note.id)
            results.append(note)
        i = i + 1
        print "%d " % len(results)
    return results