|
@@ -12,6 +12,7 @@ from applications.const import updateAccountReadRateTaskConst
|
|
|
|
|
|
const = updateAccountReadRateTaskConst()
|
|
|
functions = Functions()
|
|
|
+read_rate_table = "long_articles_read_rate_dev"
|
|
|
|
|
|
|
|
|
def filter_outlier_data(group, key='show_view_count'):
|
|
@@ -142,7 +143,7 @@ def cal_account_read_rate(gh_id_tuple) -> DataFrame:
|
|
|
)
|
|
|
for line in account_article_detail:
|
|
|
gh_id = line['ghId']
|
|
|
- dt = functions.timestamp_to_str(timestamp=['publish_timestamp'], string_format='%Y-%m-%d')
|
|
|
+ dt = functions.timestamp_to_str(timestamp=line['publish_timestamp'], string_format='%Y-%m-%d')
|
|
|
fans = fans_dict_each_day.get(gh_id, {}).get(dt, 0)
|
|
|
line['fans'] = fans
|
|
|
if fans > 1000:
|
|
@@ -193,7 +194,7 @@ def check_each_position(db_client, gh_id, index, dt, avg_rate) -> dict:
|
|
|
dt = int(dt.replace("-", ""))
|
|
|
select_sql = f"""
|
|
|
SELECT account_name, read_rate_avg
|
|
|
- FROM long_articles_read_rate
|
|
|
+ FROM {read_rate_table}
|
|
|
WHERE gh_id = '{gh_id}' and position = {index} and dt_version < {dt}
|
|
|
ORDER BY dt_version DESC limit 1;
|
|
|
"""
|
|
@@ -262,7 +263,7 @@ def update_single_day(dt, account_list, article_df, lam):
|
|
|
if not read_rate_avg:
|
|
|
continue
|
|
|
insert_sql = f"""
|
|
|
- INSERT INTO long_articles_read_rate
|
|
|
+ INSERT INTO {read_rate_table}
|
|
|
(account_name, gh_id, position, read_rate_avg, remark, articles_count, earliest_publish_time, latest_publish_time, dt_version, is_delete)
|
|
|
values
|
|
|
(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s);
|
|
@@ -286,27 +287,29 @@ def update_single_day(dt, account_list, article_df, lam):
|
|
|
insert_error_list.append(e)
|
|
|
|
|
|
if insert_error_list:
|
|
|
- bot(
|
|
|
- title="更新阅读率均值,存在sql 插入失败",
|
|
|
- detail=insert_error_list
|
|
|
- )
|
|
|
+ # bot(
|
|
|
+ # title="更新阅读率均值,存在sql 插入失败",
|
|
|
+ # detail=insert_error_list
|
|
|
+ # )
|
|
|
+ print(insert_error_list)
|
|
|
|
|
|
if error_list:
|
|
|
- bot(
|
|
|
- title="更新阅读率均值,头次出现异常值通知",
|
|
|
- detail={
|
|
|
- "时间": dt,
|
|
|
- "异常列表": error_list
|
|
|
- }
|
|
|
- )
|
|
|
-
|
|
|
- if not error_list and not insert_error_list:
|
|
|
- bot(
|
|
|
- title="阅读率均值表,更新成功",
|
|
|
- detail={
|
|
|
- "日期": dt
|
|
|
- }
|
|
|
- )
|
|
|
+ # bot(
|
|
|
+ # title="更新阅读率均值,头次出现异常值通知",
|
|
|
+ # detail={
|
|
|
+ # "时间": dt,
|
|
|
+ # "异常列表": error_list
|
|
|
+ # }
|
|
|
+ # )
|
|
|
+ print(error_list)
|
|
|
+
|
|
|
+ # if not error_list and not insert_error_list:
|
|
|
+ # bot(
|
|
|
+ # title="阅读率均值表,更新成功",
|
|
|
+ # detail={
|
|
|
+ # "日期": dt
|
|
|
+ # }
|
|
|
+ # )
|
|
|
|
|
|
|
|
|
def main() -> None:
|