소스 검색

增加 table long_articles_publishing_accounts

通过账号的 is_using 字段来控制
official_articles_v2的 status
罗俊辉 7 달 전
부모
커밋
c210ac0519
1개의 변경된 파일23개의 추가작업 그리고 3개의 파일을 삭제
  1. 23 3
      updatePublishedMsgDaily.py

+ 23 - 3
updatePublishedMsgDaily.py

@@ -28,6 +28,19 @@ def get_accounts_v1():
     return subscription_account, server_account
 
 
+def get_account_using_status():
+    """
+    获取正在 using 的 ghid
+    :return:
+    """
+    sql = "SELECT gh_id FROM long_articles_publishing_accounts WHERE is_using = 1;"
+    gh_id_tuple = PQMySQL().select(sql)
+    gh_id_list = [
+        i[0] for i in gh_id_tuple
+    ]
+    return set(gh_id_list)
+
+
 def get_accounts():
     """
     从 aigc 数据库中获取目前处于发布状态的账号
@@ -39,7 +52,15 @@ def get_accounts():
     "account_type": line[4],
     "account_auth": line[5]
     """
-    account_list = aiditApi.get_publish_account_from_aigc()
+    using_account_set = get_account_using_status()
+    account_list_with_out_using_status = aiditApi.get_publish_account_from_aigc()
+    account_list = []
+    for item in account_list_with_out_using_status:
+        if item['ghId'] in using_account_set:
+            item['using_status'] = 1
+        else:
+            item['using_status'] = 0
+        account_list.append(item)
     subscription_account = [i for i in account_list if i['account_type'] in {0, 1}]
     server_account = [i for i in account_list if i['account_type'] == 2]
     return subscription_account, server_account
@@ -55,7 +76,6 @@ def insert_each_msg(db_client, item, account_name, msg_list):
     :return:
     """
     gh_id = item['ghId']
-    account_init_timestamp = item['account_init_timestamp']
     for info in msg_list:
         baseInfo = info.get("BaseInfo", {})
         appMsgId = info.get("AppMsg", {}).get("BaseInfo", {}).get("AppMsgId", None)
@@ -83,7 +103,7 @@ def insert_each_msg(db_client, item, account_name, msg_list):
                 show_zs_count = show_stat.get("show_zs_count", 0)
                 show_pay_count = show_stat.get("show_pay_count", 0)
                 wx_sn = ContentUrl.split("&sn=")[1].split("&")[0] if ContentUrl else None
-                status = 1 if int(time.time()) - account_init_timestamp > 14 * 24 * 3600 else 0
+                status = item['using_status']
                 info_tuple = (
                     gh_id,
                     account_name,