|
@@ -74,6 +74,8 @@ class CronDelDataView(View):
|
|
|
return self.delTesterDevice(response)
|
|
|
elif operation == 'delAppLog': # 定时删除app日志
|
|
|
return self.delAppLog(response)
|
|
|
+ elif operation == 'delDeviceLog': # 定时删除设备日志
|
|
|
+ return self.delDeviceLog(response)
|
|
|
elif operation == 'UpdateConfiguration': # 定时更新配置
|
|
|
return self.UpdateConfiguration(response)
|
|
|
elif operation == 'cloud-log':
|
|
@@ -174,6 +176,26 @@ class CronDelDataView(View):
|
|
|
except Exception as e:
|
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
|
|
+ @staticmethod
|
|
|
+ def delDeviceLog(response):
|
|
|
+ """
|
|
|
+ 定时删除设备日志
|
|
|
+ @param response: 响应对象
|
|
|
+ @return:
|
|
|
+ """
|
|
|
+ nowTime = int(time.time())
|
|
|
+ size = 5000
|
|
|
+ try:
|
|
|
+ cursor = connection.cursor()
|
|
|
+ month_ago_time = nowTime - 30 * 24 * 60 * 60 # 保留近30天的数据
|
|
|
+ month_ago_time_str = CommonService.timestamp_to_str(month_ago_time)
|
|
|
+ sql = "DELETE FROM `device_log` WHERE add_time<'{}' LIMIT {}".format(month_ago_time_str, size)
|
|
|
+ cursor.execute(sql)
|
|
|
+ cursor.close()
|
|
|
+ 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 uid_cloud_storage_upload_count(response):
|
|
|
try:
|