|
@@ -49,6 +49,8 @@ class CronDelDataView(View):
|
|
|
return self.delAccessLog(response)
|
|
|
elif operation == 'delPushInfo': # 定时删除推送数据
|
|
|
return self.delPushInfo(response)
|
|
|
+ elif operation == 'delPushInfoV2': # 定时删除推送数据V2
|
|
|
+ return self.delPushInfoV2(response)
|
|
|
elif operation == 'delVodHls': # 定时删除云存播放列表
|
|
|
return self.delVodHls(response)
|
|
|
elif operation == 'delCloudLog': # 定时删除云存接口数据
|
|
@@ -255,6 +257,34 @@ class CronDelDataView(View):
|
|
|
# 关闭游标
|
|
|
cursor.close()
|
|
|
|
|
|
+ @classmethod
|
|
|
+ def delPushInfoV2(cls, response):
|
|
|
+ try:
|
|
|
+ del_push_info_thread = threading.Thread(
|
|
|
+ target=cls.del_push_info_data_v2)
|
|
|
+ del_push_info_thread.start()
|
|
|
+ return response.json(0)
|
|
|
+ except Exception as e:
|
|
|
+ return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
+
|
|
|
+ @staticmethod
|
|
|
+ def del_push_info_data_v2():
|
|
|
+ cursor = connections['mysql02'].cursor()
|
|
|
+
|
|
|
+ # 获取7天前时间戳
|
|
|
+ now_time = int(time.time())
|
|
|
+ expiration_time = LocalDateTimeUtil.get_before_days_timestamp(now_time, 7)
|
|
|
+
|
|
|
+ # 每次删除条数
|
|
|
+ size = 5000
|
|
|
+
|
|
|
+ for i in range(1, 21):
|
|
|
+ sql = "DELETE FROM equipment_info_{} WHERE add_time< %s LIMIT %s ".format(i)
|
|
|
+ cursor.execute(sql, [expiration_time, size])
|
|
|
+
|
|
|
+ # 关闭游标
|
|
|
+ cursor.close()
|
|
|
+
|
|
|
@staticmethod
|
|
|
def delVodHls(response):
|
|
|
nowTime = int(time.time())
|