|
@@ -5,7 +5,7 @@ import json
|
|
|
import time
|
|
|
import schedule
|
|
|
from tqdm import tqdm
|
|
|
-from datetime import datetime
|
|
|
+from datetime import datetime, timedelta
|
|
|
|
|
|
from applications import longArticlesMySQL, PQMySQL, DeNetMysql, Functions
|
|
|
|
|
@@ -39,7 +39,7 @@ class UpdateAccountInfoVersion3(object):
|
|
|
D[account_name][dt] = fans
|
|
|
else:
|
|
|
D[account_name] = {dt: fans}
|
|
|
- print(json.dumps(D, ensure_ascii=False, indent=4))
|
|
|
+ # print(json.dumps(D, ensure_ascii=False, indent=4))
|
|
|
return D
|
|
|
|
|
|
@classmethod
|
|
@@ -72,7 +72,7 @@ class UpdateAccountInfoVersion3(object):
|
|
|
temp[4] = fans_dict.get(temp[3], {}).get(dt, 0)
|
|
|
temp[-1] = rate_dict.get(temp[3], {}).get(temp[1], 0)
|
|
|
temp[5] = fans_dict.get(temp[3], {}).get(dt, 0) * rate_dict.get(temp[3], {}).get(temp[1], 0)
|
|
|
- print(temp)
|
|
|
+ temp[7] = 1
|
|
|
usql = f"""
|
|
|
INSERT INTO account_avg_info_v3
|
|
|
(gh_id, position, update_time, account_name, fans, read_avg, like_avg, status, account_type, account_mode, account_source, account_status, business_type, read_rate_avg)
|
|
@@ -105,6 +105,19 @@ class UpdateAccountInfoVersion3(object):
|
|
|
except Exception as e:
|
|
|
print(e)
|
|
|
|
|
|
+ # 修改前一天的状态为 0
|
|
|
+ uuu_sql = f"""
|
|
|
+ UPDATE account_avg_info_v3
|
|
|
+ SET status = %s
|
|
|
+ where update_time != %s and account_name = %s and position = %s;
|
|
|
+ """
|
|
|
+ cls.pq.update(
|
|
|
+ sql=uuu_sql,
|
|
|
+ params=(
|
|
|
+ 0, dt, temp[3], temp[1]
|
|
|
+ )
|
|
|
+ )
|
|
|
+
|
|
|
|
|
|
def updateDaily():
|
|
|
"""
|
|
@@ -114,18 +127,21 @@ def updateDaily():
|
|
|
Up = UpdateAccountInfoVersion3()
|
|
|
fd = Up.getAccountFans()
|
|
|
rd = Up.getAccountRate()
|
|
|
- today_dt = datetime.today().__str__().split(" ")[0]
|
|
|
- # today_dt = '2024-09-12'
|
|
|
- Up.reverseSingleDay(today_dt, fd, rd)
|
|
|
+ dt_object = datetime.fromtimestamp(int(time.time()))
|
|
|
+ one_day = timedelta(days=1)
|
|
|
+ yesterday = dt_object - one_day
|
|
|
+ yesterday_str = yesterday.strftime('%Y-%m-%d')
|
|
|
+ # print(yesterday_str)
|
|
|
+ Up.reverseSingleDay(yesterday_str, fd, rd)
|
|
|
Up.lam.close()
|
|
|
Up.pq.close()
|
|
|
Up.de.close()
|
|
|
|
|
|
|
|
|
-# if __name__ == '__main__':
|
|
|
+if __name__ == '__main__':
|
|
|
+ # updateDaily()
|
|
|
+ schedule.every().day.at("10:15").do(Functions().job_with_thread, updateDaily)
|
|
|
|
|
|
- # schedule.every().day.at("10:15").do(Functions().job_with_thread, updateDaily)
|
|
|
- #
|
|
|
- # while True:
|
|
|
- # schedule.run_pending()
|
|
|
- # time.sleep(1)
|
|
|
+ while True:
|
|
|
+ schedule.run_pending()
|
|
|
+ time.sleep(1)
|