Django Basic Statistics Generation

Note: This is work in progress take this as some

Seen by hour (will show same device multiple times)

qs=models.RemoteBluetoothDeviceFoundRecord.objects.filter(time__isnull=False). # force SELECT time
        extra(select={'hour':"date_part('hour',time)"}) # extract minute
qs.query.group_by=['remote_id','hour']
qs=qs.annotate(Count('remote')).order_by('hour')
 
for hour,count,remote in qs.values_list('hour','remote__count','remote'):
    print hour,count,remote
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License