diff --git a/BDSM/commands.py b/BDSM/commands.py index 91cdd86..f98e36b 100644 --- a/BDSM/commands.py +++ b/BDSM/commands.py @@ -30,20 +30,25 @@ def analysis(): import jieba import re - year_toots = Toot.query.filter(extract('year', Toot.created_at) == 2022) - print("2022 总计嘟文" + str(len(year_toots.all()))) - print("2022 年发言最多天数排名" + + year = input(" 请输入要分析的年份。") + settings = Settings.query.first() + + year_toots = Toot.query.filter(extract('year', Toot.created_at) == int(year)) + print(f"{year} 总计嘟文" + str(len(year_toots.all()))) + print(f"{year} 年发言最多天数排名" + str(db.session.query(func.strftime("%Y-%m-%d", Toot.created_at ).label('date'),func.count('date') - ).filter(extract('year', Toot.created_at) == 2022 + ).filter(extract('year', Toot.created_at) == int(year) + ).filter(Toot.acct==settings.account ).group_by('date' ).order_by(desc(func.count('date')) ).all()[:3]) ) - print("2022 年互动最多帐号排名" + + print(f"{year} 年互动最多帐号排名" + str(db.session.query(Toot.acct.label('count'),func.count('count') - ).filter(extract('year', Toot.created_at) == 2022 + ).filter(extract('year', Toot.created_at) == int(year) + ).filter(Toot.acct!=settings.account ).group_by('count' ).order_by(desc(func.count('count')) ).all()[:3]) @@ -71,8 +76,8 @@ def analysis(): if i.visibility == 'public': public_counter += 1 - print("2022 实际有内容嘟文数量:" + str(toots_counter)) - print("2022 公开嘟文数量" + str(public_counter)) + print(f"{year} 实际有内容嘟文数量:" + str(toots_counter)) + print(f"{year} 公开嘟文数量" + str(public_counter)) jieba.load_userdict(r'misc/user_dict.txt') wordlist = jieba.lcut(toots_content) diff --git a/pyproject.toml b/pyproject.toml index 6eeefdb..deea276 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ readme = "README.md" packages = [{include = "mastodon_bdsm"}] [tool.poetry.dependencies] -python = "3.11.2" +python = "3.11.3" wordcloud = "^1.9.1.1" blurhash = "1.1.4" certifi = "2022.12.7"