瀏覽代碼

更新账号均值代码上线

罗俊辉 9 月之前
父節點
當前提交
86c0c1c7a5
共有 3 個文件被更改,包括 33 次插入16 次删除
  1. 19 1
      long_articles_job.sh
  2. 1 1
      migrateRootSourceId.py
  3. 13 14
      updateAccountAvgDaily.py

+ 19 - 1
long_articles_job.sh

@@ -80,4 +80,22 @@ else
     # 在后台运行 Python 脚本并重定向日志输出
     nohup python3 updateMinigramInfoDaily.py >> /dev/null 2>&1 &
     echo "$(date '+%Y-%m-%d %H:%M:%S') - successfully restart updateMinigramInfoDaily.py"
-fi
+fi
+
+# 自动更新账号均值
+if pgrep -f "python3 updateAccountAvgDaily.py" > /dev/null
+then
+    echo "$(date '+%Y-%m-%d %H:%M:%S') - python3 updateAccountAvgDaily.py running"
+else
+    echo "$(date '+%Y-%m-%d %H:%M:%S') - trying to restart python3 updateAccountAvgDaily.py"
+    # 切换到指定目录
+    cd /root/luojunhui/LongArticlesJob
+
+    # 激活 Conda 环境
+    source /root/miniconda3/etc/profile.d/conda.sh
+    conda activate tasks
+
+    # 在后台运行 Python 脚本并重定向日志输出
+    nohup python3 python3 updateAccountAvgDaily.py >> /dev/null 2>&1 &
+    echo "$(date '+%Y-%m-%d %H:%M:%S') - successfully restart updateAccountAvgDaily.py"
+fi

+ 1 - 1
migrateRootSourceId.py

@@ -46,7 +46,7 @@ class UpdateRootSourceId(object):
         :param request_time_stamp:
         :return:
         """
-        start_dt = request_time_stamp - 24 * 3600
+        start_dt = request_time_stamp - 6 * 24 * 3600
         sql = f"""
             select trace_id, gh_id, account_name, article_title, result1, result2, result3, request_time_stamp
             from long_articles_video 

+ 13 - 14
updateAccountAvgDaily.py

@@ -56,20 +56,12 @@ class UpdateAvgDaily(object):
         :return:
         """
         sql = f"""
-        SELECT t1.`name`,t1.gh_id, t1.follower_count
+        SELECT t1.`name`, t1.gh_id, t1.follower_count, t3.account_type
         FROM `publish_account` t1
         JOIN wx_statistics_group_source_account t2
-        ON t1.id = t2.account_id
-        UNION
-        SELECT t1.`name`, t1.gh_id, t1.follower_count
-        FROM `publish_account` t1
-        where t1.`name` in (
-                            '晚年家人',
-                            '历史长河流淌',
-                            '史趣探秘',
-                            '暖心一隅',
-                            '小阳看天下',
-                            '小惠爱厨房');
+            ON t1.id = t2.account_id
+        JOIN wx_statistics_group_source t3
+            ON t2.group_source_name = t3.account_source_name
         """
         response = cls.deNetClient.select(sql)
         L = []
@@ -77,9 +69,15 @@ class UpdateAvgDaily(object):
             temp = {
                 "accountName": item[0],
                 "ghId": item[1],
-                "fans": item[2]
+                "fans": item[2],
+                "accountType": item[3]
             }
-            L.append(temp)
+            if temp["accountName"] in ['口琴', '二胡']:
+                continue
+            elif temp["accountType"] == '服务号':
+                continue
+            else:
+                L.append(temp)
         return L
 
     @classmethod
@@ -231,6 +229,7 @@ def updateAvgJob():
 
 
 if __name__ == "__main__":
+    # updateAvgJob()
     schedule.every().day.at("22:30").do(Functions().job_with_thread, updateAvgJob)
 
     while True: