# get return 2 bug fixed

This commit is contained in:
xianfuxing 2018-08-20 18:24:45 +08:00
parent e0e3c46533
commit 3b6ac9ef13
1 changed files with 2 additions and 1 deletions

View File

@ -61,7 +61,8 @@ class DeviceLogStatisticAPIView(APIView):
def get(self, request, *args, **kwargs):
# calc total count, no cache
total_count_queryset = [DeviceCount.objects.get(device_id=x['device_id'], data_time=x['max_time'])
total_count_queryset = [DeviceCount.objects.filter(device_id=x['device_id'],
data_time=x['max_time']).order_by('-count')[0]
for x in DeviceCount.objects.values('device_id').annotate(max_time=Max('data_time'))]
if total_count_queryset:
total_count = sum(map(lambda x: int(x.count), total_count_queryset))