(request)
return data
Traffic as post views in the last 60 min.
Traffic as post views in the last 60 min.
Traffic as post views in the last 60 min .
def traffic(request):
    """
    Traffic as post views in the last 60 min.
    """
    now = datetime.now()
    start = now - timedelta(minutes=60)
    start = start.now()
    post_views = PostView.objects.filter(date__gt=start).exclude(date__gt=now).distinct('ip').count()

    data = {
        'date': util.datetime_to_iso(now),
        'timestamp': util.datetime_to_unix(now),
        'post_views_last_60_min': post_views,
    }
    return data
def traffic ( request ) : now = datetime . now ( ) start = now - timedelta ( minutes = 60 ) start = start . now ( ) post_views = PostView . objects . filter ( date__gt = start ) . exclude ( date__gt = now ) . distinct ( 'ip' ) . count ( ) data = { 'date' : util . datetime_to_iso ( now ) , 'timestamp' : util . datetime_to_unix ( now ) , 'post_views_last_60_min' : post_views , } return data