Parcourir la source

新增删除三个月之前的cloud_log数据接口

locky il y a 3 ans
Parent
commit
3d01464d97
2 fichiers modifiés avec 13 ajouts et 2 suppressions
  1. 1 0
      Ansjer/urls.py
  2. 12 2
      Controller/CloudStorage.py

+ 1 - 0
Ansjer/urls.py

@@ -208,6 +208,7 @@ urlpatterns = [
     # 删除云存视频
     # path('cv/del', CloudVod.deleteVodHls),
     path('cv/del', CloudStorage.deleteVodHls),
+    path('cv/delCloudLog', CloudStorage.deleteCloudLog),
     path('cv/updateExpiredUidBucket', CloudStorage.updateExpiredUidBucket),
     path('cv/updateUnusedUidBucket', CloudStorage.updateUnusedUidBucket),
     url(r'^equipment/judge', EquipmentManager.judgeInterface),

+ 12 - 2
Controller/CloudStorage.py

@@ -40,7 +40,7 @@ from Ansjer.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, OSS_ROLE_AR
 from Controller.CheckUserData import DataValid
 from Model.models import Device_Info, Order_Model, Store_Meal, VodHlsModel, OssCrdModel, UID_Bucket, StsCrdModel, \
     ExperienceContextModel, Pay_Type, CDKcontextModel, Device_User, SysMassModel, SysMsgModel, UidPushModel, \
-    Unused_Uid_Meal, UIDMainUser, UserModel, PromotionRuleModel, VideoPlaybackTimeModel
+    Unused_Uid_Meal, UIDMainUser, UserModel, PromotionRuleModel, VideoPlaybackTimeModel, CloudLogModel
 from Object.AWS.S3Email import S3Email
 from Object.AliPayObject import AliPayObject
 from Object.AliSmsObject import AliSmsObject
@@ -1940,4 +1940,14 @@ def updateUnusedUidBucket(request):
         except Exception:
             continue
     # UID_Bucket.objects.filter(id__in=list(id_list)).update(use_status=2)  # 更新过期云存关联套餐状态
-    return response.json(0)
+    return response.json(0)
+
+# 删除三个月之前的cloud_log数据
+def deleteCloudLog(request):
+    response = ResponseObject()
+    delTime = int(time.time()) - 3 * 30 * 24 * 60 * 60  # 保留3个月的数据
+    for i in range(5):
+        cloud_log_qs = CloudLogModel.objects.filter(time__lte=delTime)[0:10000]
+        id_list = cloud_log_qs.values_list('id', flat=True)
+        CloudLogModel.objects.filter(id__in=list(id_list)).delete()
+    return response.json(0)