|
@@ -846,25 +846,25 @@ def content_rank(user_id, start, end, page, page_size, order, order_by, book, ch
|
|
op_time_small = f" and dt<='{end}' " if end else ''
|
|
op_time_small = f" and dt<='{end}' " if end else ''
|
|
|
|
|
|
db = MysqlUtils().dm
|
|
db = MysqlUtils().dm
|
|
-
|
|
|
|
|
|
+ total = db.getData(f"select sum(if(title,1,0))+sum(if(description,1,0)) from dw_image_cost_day dicd ")[0][0]
|
|
|
|
+ title_totle = db.getData(f"select sum(if(title,1,0)) from dw_image_cost_day dicd ")[0][0]
|
|
|
|
+ des_totle = db.getData(f"select sum(if(description,1,0)) from dw_image_cost_day dicd ")[0][0]
|
|
|
|
+ end_title = int((page * page_size) / total * title_totle) + 1
|
|
|
|
+ start_title = int(((page - 1) * page_size) / total * title_totle)
|
|
|
|
+ end_des = int((page * page_size) / total * des_totle) + 1
|
|
|
|
+ start_des = int(((page - 1) * page_size) / total * des_totle)
|
|
|
|
+ print(page, page_size, start_title, end_title, start_des, end_des)
|
|
sql = f"""
|
|
sql = f"""
|
|
- select
|
|
|
|
|
|
+ select * from (select
|
|
row_number () over() as id,
|
|
row_number () over() as id,
|
|
book as novels,
|
|
book as novels,
|
|
dt as startDate,
|
|
dt as startDate,
|
|
date_format( now(),'%Y-%m-%d') as endDate,
|
|
date_format( now(),'%Y-%m-%d') as endDate,
|
|
- `type` as channel,
|
|
|
|
|
|
+ 1 as type,
|
|
'all' as dataType,
|
|
'all' as dataType,
|
|
owner as creator,
|
|
owner as creator,
|
|
- 0 as delFlag,
|
|
|
|
False as isCollected,
|
|
False as isCollected,
|
|
'' as labels,
|
|
'' as labels,
|
|
- download_path as downloadPath,
|
|
|
|
- height,
|
|
|
|
- width,
|
|
|
|
- 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,round(click_count / view_count,2)) 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,
|
|
round(width/if(height,height,1),2) aspect_ratio,
|
|
cost as consumeAmount,
|
|
cost as consumeAmount,
|
|
@@ -873,23 +873,51 @@ def content_rank(user_id, start, end, page, page_size, order, order_by, book, ch
|
|
round((cost/view_count)*1000,2) cpm,
|
|
round((cost/view_count)*1000,2) cpm,
|
|
round(click_count/view_count,4) ctr,
|
|
round(click_count/view_count,4) ctr,
|
|
round(cost/click_count,2) cpc,
|
|
round(cost/click_count,2) cpc,
|
|
- title,
|
|
|
|
- description as article,
|
|
|
|
|
|
+ REPLACE(REPLACE(description , CHAR(10), ''), CHAR(13), '') as content ,
|
|
date_format( now(),'%Y-%m-%d %H:%i:%S') as upateTime,
|
|
date_format( now(),'%Y-%m-%d %H:%i:%S') as upateTime,
|
|
null as updateBy,
|
|
null as updateBy,
|
|
- if(is_video,2,1) as type,
|
|
|
|
- video_bit_rate as videoBitRate,
|
|
|
|
- null as videoFirstPage,
|
|
|
|
- video_length as videoLength,
|
|
|
|
use_times as userTimes
|
|
use_times as userTimes
|
|
from dw_image_cost_day
|
|
from dw_image_cost_day
|
|
where replace (preview_url,' ,','') !=''
|
|
where replace (preview_url,' ,','') !=''
|
|
and (1=1 {op1} {op4} {op10} {op11} {op12} {op_or1})
|
|
and (1=1 {op1} {op4} {op10} {op11} {op12} {op_or1})
|
|
{op_time_bigger} {op_time_small}
|
|
{op_time_bigger} {op_time_small}
|
|
|
|
+ limit {start_title} , {end_title}) as a
|
|
|
|
+union all
|
|
|
|
+select * from (select
|
|
|
|
+ row_number () over() as id,
|
|
|
|
+ book as novels,
|
|
|
|
+ dt as startDate,
|
|
|
|
+ date_format( now(),'%Y-%m-%d') as endDate,
|
|
|
|
+ 2 as type,
|
|
|
|
+ 'all' as dataType,
|
|
|
|
+ owner as creator,
|
|
|
|
+ False as isCollected,
|
|
|
|
+ '' as labels,
|
|
|
|
+ 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,
|
|
|
|
+ click_count as clickTimes,
|
|
|
|
+ round((cost/view_count)*1000,2) cpm,
|
|
|
|
+ round(click_count/view_count,4) ctr,
|
|
|
|
+ round(cost/click_count,2) cpc,
|
|
|
|
+ REPLACE(REPLACE(title, CHAR(10), ''), CHAR(13), '') as content ,
|
|
|
|
+ date_format( now(),'%Y-%m-%d %H:%i:%S') as upateTime,
|
|
|
|
+ null as updateBy,
|
|
|
|
+ use_times as userTimes
|
|
|
|
+ from dw_image_cost_day
|
|
|
|
+ where replace (preview_url,' ,','') !=''
|
|
|
|
+ and (1=1 {op1} {op4} {op10} {op11} {op12} {op_or1})
|
|
|
|
+ {op_time_bigger} {op_time_small}
|
|
|
|
+ limit {start_des} , {end_des}
|
|
|
|
+ ) as b
|
|
|
|
+
|
|
{op_order}
|
|
{op_order}
|
|
"""
|
|
"""
|
|
print(sql)
|
|
print(sql)
|
|
- data, total = getLimitData(db, sql, page, page_size)
|
|
|
|
|
|
+
|
|
|
|
+ data = db.getData_json(sql)
|
|
|
|
+
|
|
data = {'records': data, 'total': total, 'size': page_size, 'current': page, 'pages': int(total / page_size) + 1}
|
|
data = {'records': data, 'total': total, 'size': page_size, 'current': page, 'pages': int(total / page_size) + 1}
|
|
return data
|
|
return data
|
|
|
|
|