Pārlūkot izejas kodu

设备日志保留7天

locky 1 nedēļu atpakaļ
vecāks
revīzija
bc9396c07f
1 mainītis faili ar 2 papildinājumiem un 2 dzēšanām
  1. 2 2
      Controller/Cron/CronTaskController.py

+ 2 - 2
Controller/Cron/CronTaskController.py

@@ -453,9 +453,9 @@ class CronDelDataView(View):
         nowTime = int(time.time())
         try:
             cursor = connection.cursor()
-            month_ago_time = nowTime - 30 * 24 * 60 * 60  # 保留近30天的数据
+            expired_time = nowTime - 7 * 24 * 60 * 60  # 保留近7天的数据
 
-            sql = 'DELETE FROM `device_log` WHERE unix_timestamp(add_time)<{}'.format(month_ago_time)
+            sql = 'DELETE FROM `device_log` WHERE unix_timestamp(add_time)<{}'.format(expired_time)
             cursor.execute(sql)
             cursor.close()
             return response.json(0)