| 
					
				 | 
			
			
				@@ -8,7 +8,7 @@ from tqdm import tqdm 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 from datetime import datetime, timedelta 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 from argparse import ArgumentParser 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-from applications import PQMySQL, DeNetMysql 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+from applications import PQMySQL, DeNetMysql, longArticlesMySQL 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 TOULIU_ACCOUNTS = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     'gh_93e00e187787', 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -22,20 +22,6 @@ ARTICLES_DAILY = 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 TOULIU = 2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def get_account_position_read_rate(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    :return: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    with open("./config/account_read_rate_map.json", encoding="utf-8") as f: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        data = json.loads(f.read()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    read_rate_dict = {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    for item in data: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        key = "{}_{}".format(item['gh_id'], item['position']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        values = item['read_rate_avg'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        read_rate_dict[key] = values 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    return read_rate_dict 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 class UpdateAccountInfoVersion3(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     更新账号信息 v3 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -44,6 +30,28 @@ class UpdateAccountInfoVersion3(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     def __init__(self): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         self.pq = PQMySQL() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         self.de = DeNetMysql() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        self.lam = longArticlesMySQL() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    def get_account_position_read_rate(self): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        从长文数据库获取账号阅读均值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        :return: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        sql = f""" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            SELECT  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                gh_id, position, read_rate_avg 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            FROM 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                long_articles_read_rate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        result = self.lam.select(sql) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        account_read_rate_dict = {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for item in result: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            gh_id = item[0] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            position = item[1] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            rate = item[2] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            key = "{}_{}".format(gh_id, position) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            account_read_rate_dict[key] = rate 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return account_read_rate_dict 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     def get_publishing_accounts(self): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         """ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -90,7 +98,7 @@ class UpdateAccountInfoVersion3(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         do it 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         account_list = self.get_publishing_accounts() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        rate_dict = get_account_position_read_rate() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        rate_dict = self.get_account_position_read_rate() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for account in tqdm(account_list): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             business_type = TOULIU if account['gh_id'] in TOULIU_ACCOUNTS else ARTICLES_DAILY 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             fans = account['fans'] 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -185,5 +193,3 @@ def main(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 if __name__ == '__main__': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     main() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 |