فهرست منبع

保留7天内的访问接口数据

locky 3 سال پیش
والد
کامیت
5ae7d951ae
1فایلهای تغییر یافته به همراه5 افزوده شده و 3 حذف شده
  1. 5 3
      Controller/Cron/CronTaskController.py

+ 5 - 3
Controller/Cron/CronTaskController.py

@@ -51,8 +51,9 @@ class CronDelDataView(View):
     def delAccessLog(response):
         try:
             cursor = connection.cursor()
-            # 删除一个月前的数据
-            last_month = LocalDateTimeUtil.get_last_month()
+            # 删除7天前的数据
+            now_time = int(time.time())
+            last_month = LocalDateTimeUtil.get_before_days_timestamp(now_time, 7)
             sql = 'DELETE FROM access_log WHERE time < %s limit %s'
             cursor.execute(sql, [last_month, 10000])
             # 关闭游标
@@ -239,7 +240,8 @@ class CronUpdateDataView(View):
                     Unused_Uid_Meal.objects.filter(id=unused['id']).delete()
                     StsCrdModel.objects.filter(
                         uid=expired_uid_bucket['uid']).delete()  # 删除sts记录
-            except Exception:
+            except Exception as e:
+                print(repr(e))
                 continue
         return response.json(0)