|
@@ -344,6 +344,7 @@ class ParseAddCampaignOrAddGroupRequest(object):
|
|
self.res_data['group_list'] = []
|
|
self.res_data['group_list'] = []
|
|
group_cnt = 1
|
|
group_cnt = 1
|
|
batch_group_params_to_db = []
|
|
batch_group_params_to_db = []
|
|
|
|
+ batch_creative_params_to_db = []
|
|
for video in self.video:
|
|
for video in self.video:
|
|
group_uuid = str(uuid.uuid4())
|
|
group_uuid = str(uuid.uuid4())
|
|
group_name = group_params_to_db['group_name'] + '-' + str(group_cnt)
|
|
group_name = group_params_to_db['group_name'] + '-' + str(group_cnt)
|
|
@@ -364,7 +365,6 @@ class ParseAddCampaignOrAddGroupRequest(object):
|
|
|
|
|
|
# 拼装组下面创意的信息
|
|
# 拼装组下面创意的信息
|
|
creative_cnt = 1
|
|
creative_cnt = 1
|
|
- batch_creative_params_to_db = []
|
|
|
|
for image_md5 in video['imageList'][: self.advertiser_strategy['image_cnt']]:
|
|
for image_md5 in video['imageList'][: self.advertiser_strategy['image_cnt']]:
|
|
creative_uuid = str(uuid.uuid4())
|
|
creative_uuid = str(uuid.uuid4())
|
|
creative_name = creative_params_to_db['creative_name'] + '_' + str(creative_cnt)
|
|
creative_name = creative_params_to_db['creative_name'] + '_' + str(creative_cnt)
|
|
@@ -387,15 +387,16 @@ class ParseAddCampaignOrAddGroupRequest(object):
|
|
single_group_params_to_request['creative_list'].append(single_creative_params_to_request)
|
|
single_group_params_to_request['creative_list'].append(single_creative_params_to_request)
|
|
creative_cnt += 1
|
|
creative_cnt += 1
|
|
|
|
|
|
- creative_df = pd.DataFrame(batch_creative_params_to_db)
|
|
|
|
- creative_df.to_sql(name="ctop_ai_kuaishou_creative_level_operation_record",
|
|
|
|
- con=engine,
|
|
|
|
- if_exists='append',
|
|
|
|
- index=False)
|
|
|
|
-
|
|
|
|
# 组和创意信息添加到最终返回数据 group_list 中
|
|
# 组和创意信息添加到最终返回数据 group_list 中
|
|
self.res_data['group_list'].append(single_group_params_to_request)
|
|
self.res_data['group_list'].append(single_group_params_to_request)
|
|
|
|
|
|
|
|
+ # 创意层级信息批量写入数据库
|
|
|
|
+ creative_df = pd.DataFrame(batch_creative_params_to_db)
|
|
|
|
+ creative_df.to_sql(name="ctop_ai_kuaishou_creative_level_operation_record",
|
|
|
|
+ con=engine,
|
|
|
|
+ if_exists='append',
|
|
|
|
+ index=False)
|
|
|
|
+ # 组层级信息批量写入数据库
|
|
group_df = pd.DataFrame(batch_group_params_to_db)
|
|
group_df = pd.DataFrame(batch_group_params_to_db)
|
|
group_df.to_sql(name="ctop_ai_kuaishou_unit_level_operation_record",
|
|
group_df.to_sql(name="ctop_ai_kuaishou_unit_level_operation_record",
|
|
con=engine,
|
|
con=engine,
|
|
@@ -419,6 +420,8 @@ class ParseAddCampaignOrAddGroupRequest(object):
|
|
self.res_data['group_list'] = []
|
|
self.res_data['group_list'] = []
|
|
cnt = 1
|
|
cnt = 1
|
|
is_smart_cover = group_params_to_request.get('smart_cover', 0)
|
|
is_smart_cover = group_params_to_request.get('smart_cover', 0)
|
|
|
|
+ batch_group_params_to_db = []
|
|
|
|
+ batch_creative_params_to_db = []
|
|
for i in range(0, len(self.video), 5):
|
|
for i in range(0, len(self.video), 5):
|
|
group_uuid = str(uuid.uuid4())
|
|
group_uuid = str(uuid.uuid4())
|
|
group_name = group_params_to_db['group_name'] + '-' + str(cnt)
|
|
group_name = group_params_to_db['group_name'] + '-' + str(cnt)
|
|
@@ -428,11 +431,7 @@ class ParseAddCampaignOrAddGroupRequest(object):
|
|
single_group_params_to_db['group_uuid'] = group_uuid
|
|
single_group_params_to_db['group_uuid'] = group_uuid
|
|
single_group_params_to_db['group_name'] = group_name
|
|
single_group_params_to_db['group_name'] = group_name
|
|
single_group_params_to_db['create_time'] = datetime.datetime.now()
|
|
single_group_params_to_db['create_time'] = datetime.datetime.now()
|
|
- df = pd.DataFrame.from_dict(single_group_params_to_db, orient='index').T
|
|
|
|
- df.to_sql(name="ctop_ai_kuaishou_unit_level_operation_record",
|
|
|
|
- con=engine,
|
|
|
|
- if_exists='append',
|
|
|
|
- index=False)
|
|
|
|
|
|
+ batch_group_params_to_db.append(single_group_params_to_db)
|
|
|
|
|
|
# 拼装返回json的组信息
|
|
# 拼装返回json的组信息
|
|
single_group_params_to_request = group_params_to_request.copy()
|
|
single_group_params_to_request = group_params_to_request.copy()
|
|
@@ -466,11 +465,7 @@ class ParseAddCampaignOrAddGroupRequest(object):
|
|
single_creative_params_to_db['vertical_photo_ids'] = str(vertical_photo_ids)
|
|
single_creative_params_to_db['vertical_photo_ids'] = str(vertical_photo_ids)
|
|
single_creative_params_to_db['cover_image_tokens'] = str(cover_image_tokens) if not is_smart_cover else None
|
|
single_creative_params_to_db['cover_image_tokens'] = str(cover_image_tokens) if not is_smart_cover else None
|
|
single_creative_params_to_db['create_time'] = datetime.datetime.now()
|
|
single_creative_params_to_db['create_time'] = datetime.datetime.now()
|
|
- df = pd.DataFrame.from_dict(single_creative_params_to_db, orient='index').T
|
|
|
|
- df.to_sql(name="ctop_ai_kuaishou_program_creative_level_operation_record",
|
|
|
|
- con=engine,
|
|
|
|
- if_exists='append',
|
|
|
|
- index=False)
|
|
|
|
|
|
+ batch_creative_params_to_db.append(single_creative_params_to_db)
|
|
|
|
|
|
single_creative_params_to_request = creative_params_to_request.copy()
|
|
single_creative_params_to_request = creative_params_to_request.copy()
|
|
single_creative_params_to_request['creative_uuid'] = creative_uuid
|
|
single_creative_params_to_request['creative_uuid'] = creative_uuid
|
|
@@ -502,11 +497,7 @@ class ParseAddCampaignOrAddGroupRequest(object):
|
|
single_creative_params_to_db['vertical_photo_ids'] = str(vertical_photo_ids)
|
|
single_creative_params_to_db['vertical_photo_ids'] = str(vertical_photo_ids)
|
|
single_creative_params_to_db['cover_image_tokens'] = str(cover_image_tokens) if not is_smart_cover else None
|
|
single_creative_params_to_db['cover_image_tokens'] = str(cover_image_tokens) if not is_smart_cover else None
|
|
single_creative_params_to_db['create_time'] = datetime.datetime.now()
|
|
single_creative_params_to_db['create_time'] = datetime.datetime.now()
|
|
- df = pd.DataFrame.from_dict(single_creative_params_to_db, orient='index').T
|
|
|
|
- df.to_sql(name="ctop_ai_kuaishou_program_creative_level_operation_record",
|
|
|
|
- con=engine,
|
|
|
|
- if_exists='append',
|
|
|
|
- index=False)
|
|
|
|
|
|
+ batch_creative_params_to_db.append(single_creative_params_to_db)
|
|
|
|
|
|
single_creative_params_to_request = creative_params_to_request.copy()
|
|
single_creative_params_to_request = creative_params_to_request.copy()
|
|
single_creative_params_to_request['creative_uuid'] = creative_uuid
|
|
single_creative_params_to_request['creative_uuid'] = creative_uuid
|
|
@@ -520,6 +511,20 @@ class ParseAddCampaignOrAddGroupRequest(object):
|
|
cnt += 1
|
|
cnt += 1
|
|
|
|
|
|
self.res_data['group_list'].append(single_group_params_to_request)
|
|
self.res_data['group_list'].append(single_group_params_to_request)
|
|
|
|
+
|
|
|
|
+ # 创意层级信息批量写入数据库
|
|
|
|
+ creative_df = pd.DataFrame(batch_creative_params_to_db)
|
|
|
|
+ creative_df.to_sql(name="ctop_ai_kuaishou_program_creative_level_operation_record",
|
|
|
|
+ con=engine,
|
|
|
|
+ if_exists='append',
|
|
|
|
+ index=False)
|
|
|
|
+
|
|
|
|
+ # 组层级信息批量写入数据库
|
|
|
|
+ group_df = pd.DataFrame(batch_group_params_to_db)
|
|
|
|
+ group_df.to_sql(name="ctop_ai_kuaishou_unit_level_operation_record",
|
|
|
|
+ con=engine,
|
|
|
|
+ if_exists='append',
|
|
|
|
+ index=False)
|
|
self.res_data['account_id'] = self.account_id
|
|
self.res_data['account_id'] = self.account_id
|
|
self.res_data['campaign_id'] = self.campaign_id
|
|
self.res_data['campaign_id'] = self.campaign_id
|
|
|
|
|