|
@@ -8,7 +8,7 @@ from pandas import DataFrame
|
|
|
from argparse import ArgumentParser
|
|
|
from datetime import datetime
|
|
|
|
|
|
-from applications import DeNetMysql, PQMySQL, longArticlesMySQL, bot, Functions
|
|
|
+from applications import DeNetMysql, PQMySQL, longArticlesMySQL, bot, Functions, create_feishu_columns_sheet
|
|
|
from applications.const import updateAccountReadRateTaskConst
|
|
|
from config import apolloConfig
|
|
|
|
|
@@ -213,11 +213,16 @@ def check_each_position(db_client, gh_id, index, dt, avg_rate) -> dict:
|
|
|
return {}
|
|
|
else:
|
|
|
response = {
|
|
|
- "账号名称": account_name,
|
|
|
- "位置": index,
|
|
|
- "当天阅读率均值": Functions().float_to_percentage(avg_rate),
|
|
|
- "前一天阅读率均值": Functions().float_to_percentage(previous_read_rate_avg),
|
|
|
- "相对变化率": Functions().float_to_percentage(relative_value)
|
|
|
+ "account_name": account_name,
|
|
|
+ "position": index,
|
|
|
+ "read_rate_avg_yesterday": Functions().float_to_percentage(avg_rate),
|
|
|
+ "read_rate_avg_the_day_before_yesterday": Functions().float_to_percentage(previous_read_rate_avg),
|
|
|
+ "relative_change_rate": [
|
|
|
+ {
|
|
|
+ "text": Functions().float_to_percentage(relative_value),
|
|
|
+ "color": "red" if relative_value < 0 else "green"
|
|
|
+ }
|
|
|
+ ]
|
|
|
}
|
|
|
return response
|
|
|
|
|
@@ -264,7 +269,6 @@ def update_single_day(dt, account_list, article_df, lam):
|
|
|
)
|
|
|
if error_obj:
|
|
|
error_list.append(error_obj)
|
|
|
- # continue
|
|
|
try:
|
|
|
if not read_rate_avg:
|
|
|
continue
|
|
@@ -290,7 +294,7 @@ def update_single_day(dt, account_list, article_df, lam):
|
|
|
)
|
|
|
)
|
|
|
except Exception as e:
|
|
|
- insert_error_list.append(e)
|
|
|
+ insert_error_list.append(str(e))
|
|
|
|
|
|
if insert_error_list:
|
|
|
bot(
|
|
@@ -299,12 +303,24 @@ def update_single_day(dt, account_list, article_df, lam):
|
|
|
)
|
|
|
|
|
|
if error_list:
|
|
|
+ columns = [
|
|
|
+ create_feishu_columns_sheet(sheet_type="plain_text", sheet_name="account_name", display_name="账号名称"),
|
|
|
+ create_feishu_columns_sheet(sheet_type="plain_text", sheet_name="position", display_name="文章位置"),
|
|
|
+ create_feishu_columns_sheet(sheet_type="plain_text", sheet_name="read_rate_avg_yesterday",
|
|
|
+ display_name="昨日阅读率均值"),
|
|
|
+ create_feishu_columns_sheet(sheet_type="plain_text", sheet_name="read_rate_avg_the_day_before_yesterday",
|
|
|
+ display_name="前天阅读率均值"),
|
|
|
+ create_feishu_columns_sheet(sheet_type="options", sheet_name="relative_change_rate",
|
|
|
+ display_name="相对变化率")
|
|
|
+ ]
|
|
|
bot(
|
|
|
title="更新阅读率均值,头次出现异常值通知",
|
|
|
detail={
|
|
|
- "时间": dt,
|
|
|
- "异常列表": error_list
|
|
|
- }
|
|
|
+ "columns": columns,
|
|
|
+ "rows": error_list
|
|
|
+ },
|
|
|
+ table=True,
|
|
|
+ mention=False
|
|
|
)
|
|
|
|
|
|
if not error_list and not insert_error_list:
|