|
@@ -566,7 +566,6 @@ def advertisement_rank(user_id, start, end, type, page, page_size, order, order_
|
|
|
|
|
|
db = MysqlUtils().dm
|
|
|
|
|
|
- ck = CkUtils()
|
|
|
|
|
|
sql = f"""
|
|
|
select
|
|
@@ -665,7 +664,12 @@ def idea_rank(user_id, start, end, page, page_size, order, order_by, book, chann
|
|
|
else:
|
|
|
op1 = f" and pitcher in {str(user)}"
|
|
|
|
|
|
- op4 = f" and channel='{channel}'" if channel else ''
|
|
|
+ if channel == '朋友圈信息流':
|
|
|
+ channel = 'MP'
|
|
|
+ if channel == '广点通':
|
|
|
+ channel = 'GDT'
|
|
|
+
|
|
|
+ op4 = f" and type='{channel}'" if channel else ''
|
|
|
|
|
|
op10 = f" and book='{book}'" if book else ''
|
|
|
op11 = f" and image_id like '%,%' " if not is_singleimg else ''
|
|
@@ -716,7 +720,7 @@ def idea_rank(user_id, start, end, page, page_size, order, order_by, book, chann
|
|
|
preview_url as media,
|
|
|
format as mediaFormat,
|
|
|
size as mediaSize,
|
|
|
- if(click_count=0 or view_count =0 or view_count is null or click_count is null,0,click_count / view_count) as clickRate,
|
|
|
+ if(click_count=0 or view_count =0 or view_count is null or click_count is null,0,round(click_count / view_count,2)) as clickRate,
|
|
|
round(width/if(height,height,1),2) aspect_ratio,
|
|
|
cost as consumeAmount,
|
|
|
view_count as viewTimes,
|
|
@@ -786,7 +790,11 @@ def media_rank(user_id, start, end, page, page_size, order, order_by, book, chan
|
|
|
else:
|
|
|
op1 = f" and pitcher in {str(user)}"
|
|
|
|
|
|
- op4 = f" and channel='{channel}'" if channel else ''
|
|
|
+ if channel == '朋友圈信息流':
|
|
|
+ channel = 'MP'
|
|
|
+ if channel == '广点通':
|
|
|
+ channel = 'GDT'
|
|
|
+ op4 = f" and type='{channel}'" if channel else ''
|
|
|
|
|
|
op10 = f" and book='{book}'" if book else ''
|
|
|
|
|
@@ -893,7 +901,7 @@ def media_rank(user_id, start, end, page, page_size, order, order_by, book, chan
|
|
|
return data
|
|
|
|
|
|
|
|
|
-def content_rank(user_id, start, end, page, page_size, order, order_by, book, channel, data_type, campaign_ids):
|
|
|
+def content_rank(user_id, start, end, page, page_size, order, order_by, book, channel, data_type, campaign_ids):
|
|
|
# TODO:修改为clickhouse来进行数据访问
|
|
|
|
|
|
# 时间的归因-----获取到所有这段时间内的记录,并进行聚合(聚合周末再做,先把数据拿出来)
|
|
@@ -908,7 +916,11 @@ def content_rank(user_id, start, end, page, page_size, order, order_by, book, ch
|
|
|
else:
|
|
|
op1 = f" and pitcher in {str(user)}"
|
|
|
|
|
|
- op4 = f" and channel='{channel}'" if channel else ''
|
|
|
+ if channel == '朋友圈信息流':
|
|
|
+ channel = 'MP'
|
|
|
+ if channel == '广点通':
|
|
|
+ channel = 'GDT'
|
|
|
+ op4 = f" and type='{channel}'" if channel else ''
|
|
|
op10 = f" and book='{book}'" if book else ''
|
|
|
|
|
|
if campaign_ids:
|