Ver Fonte

历史遗漏素材和程序化上新模块,新增test_video_cnt为新账户做测试使用

liyuyi@c-top.com.cn há 4 anos atrás
pai
commit
41acff4a8f
1 ficheiros alterados com 23 adições e 9 exclusões
  1. 23 9
      ai_time_task_creative_handler.py

+ 23 - 9
ai_time_task_creative_handler.py

@@ -5,6 +5,7 @@ import logging
 import traceback
 import traceback
 import random
 import random
 import tornado.web
 import tornado.web
+import requests
 from concurrent_log import ConcurrentTimedRotatingFileHandler
 from concurrent_log import ConcurrentTimedRotatingFileHandler
 from utils.ConstantConfig import *
 from utils.ConstantConfig import *
 from utils.DataBaseConfig import *
 from utils.DataBaseConfig import *
@@ -35,6 +36,8 @@ class AiHistoricalMissingMaterial(tornado.web.RequestHandler):
         data = json.loads(data, encoding='utf8')
         data = json.loads(data, encoding='utf8')
         account_id = data.get('account_id')
         account_id = data.get('account_id')
         campaign_id = data.get('campaign_id')
         campaign_id = data.get('campaign_id')
+        # test_video_cnt 是给 新账户测试使用的
+        test_video_cnt = data.get('test_video_cnt', None)
         logger.info("账户信息=%s, 当前进程=%s, 当前进程的主进程=%s,  raw data from request is %s" %
         logger.info("账户信息=%s, 当前进程=%s, 当前进程的主进程=%s,  raw data from request is %s" %
                     (account_id, os.getpid(), os.getppid(), data))
                     (account_id, os.getpid(), os.getppid(), data))
         try:
         try:
@@ -52,10 +55,11 @@ class AiHistoricalMissingMaterial(tornado.web.RequestHandler):
                     if app_info['appId'] in app_id_array:
                     if app_info['appId'] in app_id_array:
                         app_dict[app_info['appVersion']] = app_info
                         app_dict[app_info['appVersion']] = app_info
                 video_list = get_missing_video_info(account_id=account_id,
                 video_list = get_missing_video_info(account_id=account_id,
-                                                    cnt=missing_video_cnt,
+                                                    cnt=test_video_cnt if test_video_cnt else missing_video_cnt,
                                                     url=get_missing_video_url,
                                                     url=get_missing_video_url,
                                                     start_time=missing_video_start_time,
                                                     start_time=missing_video_start_time,
-                                                    end_time=missing_video_end_time)
+                                                    end_time=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
+                                                    if test_video_cnt else missing_video_end_time)
                 # 返回视频中有通用视频和特定视频,需要分开处理
                 # 返回视频中有通用视频和特定视频,需要分开处理
                 # "photo_name": "all",
                 # "photo_name": "all",
                 # "photo_name": "ksjytdrca-糖豆人冲啊",
                 # "photo_name": "ksjytdrca-糖豆人冲啊",
@@ -128,10 +132,11 @@ class AiHistoricalMissingMaterial(tornado.web.RequestHandler):
                 self.flush()
                 self.flush()
             else:
             else:
                 video_info = get_missing_video_info(account_id=account_id,
                 video_info = get_missing_video_info(account_id=account_id,
-                                                    cnt=missing_video_cnt,
+                                                    cnt=test_video_cnt if test_video_cnt else missing_video_cnt,
                                                     url=get_missing_video_url,
                                                     url=get_missing_video_url,
                                                     start_time=missing_video_start_time,
                                                     start_time=missing_video_start_time,
-                                                    end_time=missing_video_end_time)
+                                                    end_time=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
+                                                    if test_video_cnt else missing_video_end_time)
                 if video_info['code'] != 0:
                 if video_info['code'] != 0:
                     logger.info("account_id = %s,补充历史遗漏素材,没有获取到视频,不发送ai策略请求!" % account_id)
                     logger.info("account_id = %s,补充历史遗漏素材,没有获取到视频,不发送ai策略请求!" % account_id)
                     self.write(json.dumps({"account_id": account_id,
                     self.write(json.dumps({"account_id": account_id,
@@ -879,6 +884,7 @@ class AiProgramCreativeNewMaterial(tornado.web.RequestHandler):
         logger.info("***************************************  NEW REQUEST ***************************************")
         logger.info("***************************************  NEW REQUEST ***************************************")
         account_id = data.get('account_id')
         account_id = data.get('account_id')
         campaign_id = data.get('campaign_id')
         campaign_id = data.get('campaign_id')
+        test_video_cnt = data.get('test_video_cnt', None)
         logger.info("账户信息=%s, 当前进程=%s, 当前进程的主进程=%s,  raw data from request is %s" %
         logger.info("账户信息=%s, 当前进程=%s, 当前进程的主进程=%s,  raw data from request is %s" %
                     (account_id, os.getpid(), os.getppid(), data))
                     (account_id, os.getpid(), os.getppid(), data))
         try:
         try:
@@ -898,9 +904,10 @@ class AiProgramCreativeNewMaterial(tornado.web.RequestHandler):
                                                     url=get_history_video_url,
                                                     url=get_history_video_url,
                                                     start_time=(datetime.datetime.now() + datetime.timedelta(days=-7)).
                                                     start_time=(datetime.datetime.now() + datetime.timedelta(days=-7)).
                                                     strftime("%Y-%m-%d %H:%M:%S"),
                                                     strftime("%Y-%m-%d %H:%M:%S"),
-                                                    end_time=(datetime.datetime.now() + datetime.timedelta(days=-1)).
-                                                    strftime("%Y-%m-%d %H:%M:%S"),
-                                                    video_cnt=multi_app_id_programme_new_video_cnt,
+                                                    end_time=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
+                                                    if test_video_cnt else
+                                                    (datetime.datetime.now() + datetime.timedelta(days=-1)).strftime("%Y-%m-%d %H:%M:%S"),
+                                                    video_cnt=test_video_cnt if test_video_cnt else multi_app_id_programme_new_video_cnt,
                                                     related_creative_max_cnt=related_creative_max_cnt)
                                                     related_creative_max_cnt=related_creative_max_cnt)
 
 
                 # 单独处理返回的时候中,有通用视频,需要单独处理
                 # 单独处理返回的时候中,有通用视频,需要单独处理
@@ -1011,9 +1018,11 @@ class AiProgramCreativeNewMaterial(tornado.web.RequestHandler):
                                                     url=get_history_video_url,
                                                     url=get_history_video_url,
                                                     start_time=(datetime.datetime.now() + datetime.timedelta(days=-7)).
                                                     start_time=(datetime.datetime.now() + datetime.timedelta(days=-7)).
                                                     strftime("%Y-%m-%d %H:%M:%S"),
                                                     strftime("%Y-%m-%d %H:%M:%S"),
-                                                    end_time=(datetime.datetime.now() + datetime.timedelta(days=-1)).
+                                                    end_time=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
+                                                    if test_video_cnt
+                                                    else (datetime.datetime.now() + datetime.timedelta(days=-1)).
                                                     strftime("%Y-%m-%d %H:%M:%S"),
                                                     strftime("%Y-%m-%d %H:%M:%S"),
-                                                    video_cnt=programme_new_video_cnt,
+                                                    video_cnt=test_video_cnt if test_video_cnt else programme_new_video_cnt,
                                                     related_creative_max_cnt=related_creative_max_cnt)
                                                     related_creative_max_cnt=related_creative_max_cnt)
                 if video_info['code'] != 0:
                 if video_info['code'] != 0:
                     self.write(json.dumps({"account_id": account_id,
                     self.write(json.dumps({"account_id": account_id,
@@ -1042,3 +1051,8 @@ class AiProgramCreativeNewMaterial(tornado.web.RequestHandler):
             logger.error("account_id = %s, traceback is %s" % (account_id, traceback.format_exc()))
             logger.error("account_id = %s, traceback is %s" % (account_id, traceback.format_exc()))
             self.write(json.dumps({"account_id": account_id, "message": traceback.format_exc(), "code": -1}))
             self.write(json.dumps({"account_id": account_id, "message": traceback.format_exc(), "code": -1}))
             self.flush()
             self.flush()
+
+
+
+
+