"""
@author: luojunhui
发布i2u2i文章
"""
import pandas as pd
from applications import DeNetMysql


class I2U2I(object):
    """
    发布账号联想文章
    """
    db = DeNetMysql()

    @classmethod
    def getAccountPositionArticles(cls, gh_id, position):
        """
        获取联想账号的某个位置的所有文章
        :return:
        """
        sql = f"""
            select title, read_cnt, link 
            from crawler_meta_article
            where out_account_id = '{gh_id}' and article_index = {position};
        """
        article_list = cls.db.select(sql)
        # df = pd.DataFrame(article_list, columns=['title', 'read_cnt', 'link'])
        # read_mean = df['read_cnt'].mean()
        # filter_response = df[
        #     (df['read_cnt'] > read_mean * 1.3)
        #     & (df['read_cnt'] > 5000)
        #     ]
        # return filter_response
        return article_list

    @classmethod
    def filter(cls):
        """
        :return:
        """
        return

if __name__ == '__main__':
    job = I2U2I()
    article_list = job.getAccountPositionArticles(gh_id='gh_e6be5a12e83c', position=1)
    for article in article_list:
        print(article)

