|
@@ -223,6 +223,21 @@ class AccountOpenRateAvgTask(AccountDataTask):
|
|
|
params_list=params_list
|
|
|
)
|
|
|
|
|
|
+ def update_record(self, gh_id, date_str, index, open_rate_obj):
|
|
|
+ avg_open_rate = open_rate_obj["avg_open_rate"]
|
|
|
+ update_sql = f"""
|
|
|
+ update account_avg_info_v3
|
|
|
+ set open_rate_avg = %s
|
|
|
+ where gh_id = %s and position = %s and update_time = %s;
|
|
|
+ """
|
|
|
+ affected_rows = self.piaoquan_crawler_db_client.save(
|
|
|
+ update_sql,
|
|
|
+ params=(
|
|
|
+ avg_open_rate, gh_id, index, date_str
|
|
|
+ )
|
|
|
+ )
|
|
|
+ print(affected_rows)
|
|
|
+
|
|
|
def get_account_open_rate(self, account_name, gh_id, date_str):
|
|
|
date_str_ = date_str.replace("-", "")
|
|
|
fetch_query = f"""
|
|
@@ -237,7 +252,9 @@ class AccountOpenRateAvgTask(AccountDataTask):
|
|
|
res = self.long_articles_db_client.fetch(
|
|
|
query=fetch_query, cursor_type=DictCursor
|
|
|
)[0]
|
|
|
- self.insert_record_into_database(gh_id=gh_id, date_str=date_str, open_rate_obj=res, account_name=account_name)
|
|
|
+ # self.insert_record_into_database(gh_id=gh_id, date_str=date_str, open_rate_obj=res, account_name=account_name)
|
|
|
+ for i in const.ARTICLE_INDEX_LIST:
|
|
|
+ self.update_record(gh_id, date_str, i, res)
|
|
|
|
|
|
def deal(self, date_str):
|
|
|
account_list = fetch_publishing_account_list(self.denet_db_client)
|