""" @author: luojunhui """ from tqdm import tqdm from applications.functions import Functions from config import accountBaseInfo class ArticlePoolStrategy(object): """ 长文策略池 """ Fun = Functions() @classmethod def getData(cls, article_list): """ :param article_list: 每天召回的文章list :return: { "Level1": [], "Level2": [], "Level3": [] } """ detail_list = [] print("查询文章url......") for i in tqdm(article_list): detail = cls.Fun.matchLinkById(i['article_id']) i['gh_id'], i['url'], i['index'] = detail detail_list.append(i) print("查询完成, 开始排序") return detail_list @classmethod def splitByStrategy(cls, detail_list): """ 账号-位置-阅读倍数 :return: """ L = [] for line in detail_list: key = "{}_{}".format(line['gh_id'], line['index']) article_read = line['increase_read_count'] avg_read = accountBaseInfo[key]['readAvg'] # 计算比率 level_rate = article_read / avg_read - 1 print(level_rate, article_read, avg_read) print(line) print("\n") obj = { "key": key, "avg_read": avg_read, "article_read": article_read, }