فهرست منبع

自主推送统计接口2

tanghongbin 5 سال پیش
والد
کامیت
d587bb6925
3فایلهای تغییر یافته به همراه17 افزوده شده و 17 حذف شده
  1. 2 2
      Controller/AdminManage.py
  2. 14 14
      Controller/StatisticsController.py
  3. 1 1
      Model/models.py

+ 2 - 2
Controller/AdminManage.py

@@ -7,7 +7,7 @@ from django.views.generic import TemplateView
 from django.utils.decorators import method_decorator
 from django.contrib.auth.hashers import make_password  # 对密码加密模块
 from Model.models import Device_Info, Role, UserExModel, User_Brand, UidSetModel, AppFrequencyYearStatisticsModel, \
-    AppFrequencyStatisticsModel, EquipmentInfoExDayStatisticsModel, EquipmentInfoExModel
+    AppFrequencyStatisticsModel, EquipmentInfoExStatisticsModel, EquipmentInfoExModel
 from Service.ModelService import ModelService
 from django.utils import timezone
 from Model.models import Access_Log, Device_User
@@ -476,7 +476,7 @@ class AdminManage(TemplateView):
 
         end_time = current_time
 
-        eqx_qs = EquipmentInfoExDayStatisticsModel.objects.filter(statistics_date__gte=start_time, statistics_date__lte=end_time, date_type=0, push_type=-1).values()
+        eqx_qs = EquipmentInfoExStatisticsModel.objects.filter(statistics_date__gte=start_time, statistics_date__lte=end_time, date_type=0, push_type=-1).values()
         data = []
 
         for i in range(count + 1):

+ 14 - 14
Controller/StatisticsController.py

@@ -7,7 +7,7 @@ from django.db.models import Count
 from django.views.decorators.csrf import csrf_exempt
 
 from Model.models import UserAppFrequencyModel, AppFrequencyStatisticsModel, Device_User, \
-    AppFrequencyYearStatisticsModel, EquipmentInfoExModel, EquipmentInfoExDayStatisticsModel
+    AppFrequencyYearStatisticsModel, EquipmentInfoExModel, EquipmentInfoExStatisticsModel
 from Object.ResponseObject import ResponseObject
 from Object.TokenObject import TokenObject
 
@@ -168,10 +168,10 @@ def statistcsPushDay(request):
     print(eq_qs.values())
     # 0:APNS推送,1:谷歌推送,2:极光推送
     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:
         if eq.push_type == 0:
             do_sum(eq, apns)
@@ -186,7 +186,7 @@ def statistcsPushDay(request):
     datas.append(jpush)
     datas.append(total)
 
-    EquipmentInfoExDayStatisticsModel.objects.bulk_create(datas)
+    EquipmentInfoExStatisticsModel.objects.bulk_create(datas)
     return response.json(0)
 
 
@@ -214,13 +214,13 @@ def statistcsPushMonth(request):
     time_struct[1] = current_month + 1
     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:极光推送
     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:
         if eq.push_type == 0:
             do_sum_two(eq, apns)
@@ -235,11 +235,11 @@ def statistcsPushMonth(request):
     datas.append(jpush)
     datas.append(total)
 
-    EquipmentInfoExDayStatisticsModel.objects.bulk_create(datas)
+    EquipmentInfoExStatisticsModel.objects.bulk_create(datas)
     return response.json(0)
 
 
-def do_sum(eq: EquipmentInfoExModel, target: EquipmentInfoExDayStatisticsModel):
+def do_sum(eq: EquipmentInfoExModel, target: EquipmentInfoExStatisticsModel):
     if eq.push_server_status == 200:
         target.number_of_successes += 1
     else:
@@ -249,7 +249,7 @@ def do_sum(eq: EquipmentInfoExModel, target: EquipmentInfoExDayStatisticsModel):
         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_failures += eq.number_of_failures
     target.number_of_arrival += eq.number_of_arrival

+ 1 - 1
Model/models.py

@@ -1005,7 +1005,7 @@ class EquipmentInfoExModel(models.Model):
         verbose_name_plural = verbose_name
 
 
-class EquipmentInfoExDayStatisticsModel(models.Model):
+class EquipmentInfoExStatisticsModel(models.Model):
     id = models.AutoField(primary_key=True)
     push_type = models.SmallIntegerField(default=0, verbose_name='第三方推送服务器标志。0:APNS推送,1:谷歌推送,2:极光推送')
     number_of_successes = models.IntegerField(default=0, verbose_name='推送成功数量')