Просмотр исходного кода

Merge branch '2024-10-19-luojunhui-check_account_info-bug-fix' of luojunhui/LongArticlesJob into master

luojunhui 6 месяцев назад
Родитель
Сommit
bc9e306f46
1 измененных файлов с 10 добавлено и 7 удалено
  1. 10 7
      updatePublishedMsgDaily.py

+ 10 - 7
updatePublishedMsgDaily.py

@@ -232,9 +232,10 @@ def update_each_account(db_client, account_info, account_name, latest_update_tim
         return
 
 
-def check_account_info(db_client, gh_id):
+def check_account_info(db_client, gh_id, account_name):
     """
     通过 gh_id查询视频信息
+    :param account_name:
     :param db_client:
     :param gh_id:
     :return:
@@ -243,19 +244,19 @@ def check_account_info(db_client, gh_id):
         SELECT accountName, updateTime 
         FROM {ARTICLE_TABLE}
         WHERE ghId = '{gh_id}' 
-        ORDER BY updateTime DESC;
+        ORDER BY updateTime DESC LIMIT 1;
         """
     result = db_client.select(sql)
     if result:
-        account_name, update_time = result[0]
+        old_account_name, update_time = result[0]
         return {
-            "account_name": account_name,
+            "account_name": old_account_name,
             "update_time": update_time,
             "account_type": "history"
         }
     else:
         return {
-            "account_name": "",
+            "account_name": account_name,
             "update_time": int(time.time()) - 30 * 24 * 60 * 60,
             "account_type": "new"
         }
@@ -269,7 +270,8 @@ def update_single_account(db_client, account_info):
     :return:
     """
     gh_id = account_info['ghId']
-    account_detail = check_account_info(db_client, gh_id)
+    account_name = account_info['name']
+    account_detail = check_account_info(db_client, gh_id, account_name)
     account_name = account_detail['account_name']
     update_time = account_detail['update_time']
     update_each_account(
@@ -297,7 +299,8 @@ def check_single_account(db_client, account_item):
             FROM {ARTICLE_TABLE}
             WHERE ghId = '{gh_id}'
             ORDER BY updateTime
-            DESC;
+            DESC
+            LIMIT 1;
             """
     try:
         latest_update_time = db_client.select(sql)[0][0]