(date)
return data
Statistics about this website for the given date.
    Statistics are stored to a json file for caching purpose.

    Parameters:
    date -- a `datetime`.
Statistics about this website for the given date.
    Statistics are stored to a json file for caching purpose.
Statistics about this website for the given date . Statistics are stored to a json file for caching purpose .
def compute_stats(date):
    """
    Statistics about this website for the given date.
    Statistics are stored to a json file for caching purpose.

    Parameters:
    date -- a `datetime`.
    """

    start = date.date()
    end = start + timedelta(days=1)

    try:
        return stat_file(date=start, load=True)
    except Exception as exc:  # This will be FileNotFoundError in Python3.
        logger.info('No stats file for {}.'.format(start))

    new_users = Profile.objects.filter(date_joined__gte=start,
                                       date_joined__lt=end).values_list("uid", flat=True)
    new_posts = Post.objects.filter(creation_date__gte=start,
                                    creation_date__lt=end).values_list("uid", flat=True)
    new_votes = Vote.objects.filter(date__gte=start,
                                    date__lt=end).values_list("id", flat=True)

    data = {
        'date': util.datetime_to_iso(start),
        'timestamp': util.datetime_to_unix(start),
        'new_users': list(new_users),
        'new_posts': list(new_posts),
        'new_votes': list(new_votes),
    }

    data.update(get_counts(end=end))

    if not settings.DEBUG:
        stat_file(dump=True, date=start, data=data)

    return data
def compute_stats ( date ) : start = date . date ( ) end = start + timedelta ( days = 1 ) try : return stat_file ( date = start , load = True ) except Exception as exc : # This will be FileNotFoundError in Python3. logger . info ( 'No stats file for {}.' . format ( start ) ) new_users = Profile . objects . filter ( date_joined__gte = start , date_joined__lt = end ) . values_list ( "uid" , flat = True ) new_posts = Post . objects . filter ( creation_date__gte = start , creation_date__lt = end ) . values_list ( "uid" , flat = True ) new_votes = Vote . objects . filter ( date__gte = start , date__lt = end ) . values_list ( "id" , flat = True ) data = { 'date' : util . datetime_to_iso ( start ) , 'timestamp' : util . datetime_to_unix ( start ) , 'new_users' : list ( new_users ) , 'new_posts' : list ( new_posts ) , 'new_votes' : list ( new_votes ) , } data . update ( get_counts ( end = end ) ) if not settings . DEBUG : stat_file ( dump = True , date = start , data = data ) return data