|
@@ -7,7 +7,7 @@ from django.db.models import Count
|
|
from django.views.decorators.csrf import csrf_exempt
|
|
from django.views.decorators.csrf import csrf_exempt
|
|
|
|
|
|
from Model.models import UserAppFrequencyModel, AppFrequencyStatisticsModel, Device_User, \
|
|
from Model.models import UserAppFrequencyModel, AppFrequencyStatisticsModel, Device_User, \
|
|
- AppFrequencyYearStatisticsModel, EquipmentInfoExModel, EquipmentInfoExDayStatisticsModel
|
|
|
|
|
|
+ AppFrequencyYearStatisticsModel, EquipmentInfoExModel, EquipmentInfoExStatisticsModel
|
|
from Object.ResponseObject import ResponseObject
|
|
from Object.ResponseObject import ResponseObject
|
|
from Object.TokenObject import TokenObject
|
|
from Object.TokenObject import TokenObject
|
|
|
|
|
|
@@ -168,10 +168,10 @@ def statistcsPushDay(request):
|
|
print(eq_qs.values())
|
|
print(eq_qs.values())
|
|
# 0:APNS推送,1:谷歌推送,2:极光推送
|
|
# 0:APNS推送,1:谷歌推送,2:极光推送
|
|
now_time = int(time.time())
|
|
now_time = int(time.time())
|
|
- jpush = EquipmentInfoExDayStatisticsModel(push_type=2, statistics_date=start_time, add_time=now_time, date_type=0)
|
|
|
|
- apns = EquipmentInfoExDayStatisticsModel(push_type=0, statistics_date=start_time, add_time=now_time, date_type=0)
|
|
|
|
- gcm = EquipmentInfoExDayStatisticsModel(push_type=1, statistics_date=start_time, add_time=now_time, date_type=0)
|
|
|
|
- total = EquipmentInfoExDayStatisticsModel(push_type=-1, statistics_date=start_time, add_time=now_time, date_type=0)
|
|
|
|
|
|
+ jpush = EquipmentInfoExStatisticsModel(push_type=2, statistics_date=start_time, add_time=now_time, date_type=0)
|
|
|
|
+ apns = EquipmentInfoExStatisticsModel(push_type=0, statistics_date=start_time, add_time=now_time, date_type=0)
|
|
|
|
+ gcm = EquipmentInfoExStatisticsModel(push_type=1, statistics_date=start_time, add_time=now_time, date_type=0)
|
|
|
|
+ total = EquipmentInfoExStatisticsModel(push_type=-1, statistics_date=start_time, add_time=now_time, date_type=0)
|
|
for eq in eq_qs:
|
|
for eq in eq_qs:
|
|
if eq.push_type == 0:
|
|
if eq.push_type == 0:
|
|
do_sum(eq, apns)
|
|
do_sum(eq, apns)
|
|
@@ -186,7 +186,7 @@ def statistcsPushDay(request):
|
|
datas.append(jpush)
|
|
datas.append(jpush)
|
|
datas.append(total)
|
|
datas.append(total)
|
|
|
|
|
|
- EquipmentInfoExDayStatisticsModel.objects.bulk_create(datas)
|
|
|
|
|
|
+ EquipmentInfoExStatisticsModel.objects.bulk_create(datas)
|
|
return response.json(0)
|
|
return response.json(0)
|
|
|
|
|
|
|
|
|
|
@@ -214,13 +214,13 @@ def statistcsPushMonth(request):
|
|
time_struct[1] = current_month + 1
|
|
time_struct[1] = current_month + 1
|
|
end_time = int(time.mktime(tuple(time_struct)))
|
|
end_time = int(time.mktime(tuple(time_struct)))
|
|
|
|
|
|
- eq_qs = EquipmentInfoExDayStatisticsModel.objects.filter(statistics_date__gte=start_time, statistics_date__lte=end_time, date_type=0)
|
|
|
|
|
|
+ eq_qs = EquipmentInfoExStatisticsModel.objects.filter(statistics_date__gte=start_time, statistics_date__lte=end_time, date_type=0)
|
|
# 0:APNS推送,1:谷歌推送,2:极光推送
|
|
# 0:APNS推送,1:谷歌推送,2:极光推送
|
|
now_time = int(time.time())
|
|
now_time = int(time.time())
|
|
- jpush = EquipmentInfoExDayStatisticsModel(push_type=2, statistics_date=start_time, add_time=now_time, date_type=1)
|
|
|
|
- apns = EquipmentInfoExDayStatisticsModel(push_type=0, statistics_date=start_time, add_time=now_time, date_type=1)
|
|
|
|
- gcm = EquipmentInfoExDayStatisticsModel(push_type=1, statistics_date=start_time, add_time=now_time, date_type=1)
|
|
|
|
- total = EquipmentInfoExDayStatisticsModel(push_type=-1, statistics_date=start_time, add_time=now_time, date_type=1)
|
|
|
|
|
|
+ jpush = EquipmentInfoExStatisticsModel(push_type=2, statistics_date=start_time, add_time=now_time, date_type=1)
|
|
|
|
+ apns = EquipmentInfoExStatisticsModel(push_type=0, statistics_date=start_time, add_time=now_time, date_type=1)
|
|
|
|
+ gcm = EquipmentInfoExStatisticsModel(push_type=1, statistics_date=start_time, add_time=now_time, date_type=1)
|
|
|
|
+ total = EquipmentInfoExStatisticsModel(push_type=-1, statistics_date=start_time, add_time=now_time, date_type=1)
|
|
for eq in eq_qs:
|
|
for eq in eq_qs:
|
|
if eq.push_type == 0:
|
|
if eq.push_type == 0:
|
|
do_sum_two(eq, apns)
|
|
do_sum_two(eq, apns)
|
|
@@ -235,11 +235,11 @@ def statistcsPushMonth(request):
|
|
datas.append(jpush)
|
|
datas.append(jpush)
|
|
datas.append(total)
|
|
datas.append(total)
|
|
|
|
|
|
- EquipmentInfoExDayStatisticsModel.objects.bulk_create(datas)
|
|
|
|
|
|
+ EquipmentInfoExStatisticsModel.objects.bulk_create(datas)
|
|
return response.json(0)
|
|
return response.json(0)
|
|
|
|
|
|
|
|
|
|
-def do_sum(eq: EquipmentInfoExModel, target: EquipmentInfoExDayStatisticsModel):
|
|
|
|
|
|
+def do_sum(eq: EquipmentInfoExModel, target: EquipmentInfoExStatisticsModel):
|
|
if eq.push_server_status == 200:
|
|
if eq.push_server_status == 200:
|
|
target.number_of_successes += 1
|
|
target.number_of_successes += 1
|
|
else:
|
|
else:
|
|
@@ -249,7 +249,7 @@ def do_sum(eq: EquipmentInfoExModel, target: EquipmentInfoExDayStatisticsModel):
|
|
target.number_of_arrival += 1
|
|
target.number_of_arrival += 1
|
|
|
|
|
|
|
|
|
|
-def do_sum_two(eq: EquipmentInfoExDayStatisticsModel, target: EquipmentInfoExDayStatisticsModel):
|
|
|
|
|
|
+def do_sum_two(eq: EquipmentInfoExStatisticsModel, target: EquipmentInfoExStatisticsModel):
|
|
target.number_of_successes += eq.number_of_successes
|
|
target.number_of_successes += eq.number_of_successes
|
|
target.number_of_failures += eq.number_of_failures
|
|
target.number_of_failures += eq.number_of_failures
|
|
target.number_of_arrival += eq.number_of_arrival
|
|
target.number_of_arrival += eq.number_of_arrival
|