Browse Source

修改时区问题导致用户数据缺失

peng 2 years ago
parent
commit
ee27519848
1 changed files with 4 additions and 7 deletions
  1. 4 7
      Controller/Cron/CronTaskController.py

+ 4 - 7
Controller/Cron/CronTaskController.py

@@ -402,13 +402,10 @@ class CronCollectDataView(View):
             created_time = int(time.time())
             today = datetime.datetime.today()
             start_time = datetime.datetime(today.year, today.month, today.day)
-            end_time = start_time + datetime.timedelta(days=1)
-            increase_user_qs = Device_User.objects.filter(data_joined__gte=start_time, data_joined__lt=end_time).values(
-                'data_joined',
-                'region_country')
-            active_user_qs = Device_User.objects.filter(last_login__gte=start_time, last_login__lt=end_time).values(
-                'last_login',
-                'region_country')
+            increase_user_qs = Device_User.objects.filter(data_joined__year=today.year, data_joined__month=today.month,
+                                                          data_joined__day=today.day).values('region_country')
+            active_user_qs = Device_User.objects.filter(last_login__year=today.year, last_login__month=today.month,
+                                                        last_login__day=today.day).values('region_country')
             start_time = CommonService.str_to_timestamp(start_time.strftime('%Y-%m-%d %H:%M:%S'))
             country_qs = CountryModel.objects.all().values('id', 'region__name', 'country_name')
             country_dict = {}