feat: top odkazy i v měsíčním přehledu
This commit is contained in:
+13
-2
@@ -127,7 +127,7 @@ def format_month_cs(dt):
|
|||||||
return f"{months[dt.month - 1]} {dt.year}"
|
return f"{months[dt.month - 1]} {dt.year}"
|
||||||
|
|
||||||
def build_monthly_toot(measures_data, tags, top_tooty, date_to, prev_stats, instance_info,
|
def build_monthly_toot(measures_data, tags, top_tooty, date_to, prev_stats, instance_info,
|
||||||
total_count=0, top_author=None, newest_account=None):
|
total_count=0, top_author=None, newest_account=None, top_links=None):
|
||||||
stats = {m["key"]: int(m["total"]) for m in measures_data}
|
stats = {m["key"]: int(m["total"]) for m in measures_data}
|
||||||
new_users = stats.get("new_users", 0)
|
new_users = stats.get("new_users", 0)
|
||||||
active_users = stats.get("active_users", 0)
|
active_users = stats.get("active_users", 0)
|
||||||
@@ -164,6 +164,15 @@ def build_monthly_toot(measures_data, tags, top_tooty, date_to, prev_stats, inst
|
|||||||
else:
|
else:
|
||||||
tooty_sekce = ""
|
tooty_sekce = ""
|
||||||
|
|
||||||
|
if top_links:
|
||||||
|
link_lines = "\n".join(
|
||||||
|
f"🔗 {link.get('title', link.get('url', ''))}\n{link.get('provider_name', '')} · {link.get('url', '')}"
|
||||||
|
for link in top_links[:3]
|
||||||
|
)
|
||||||
|
links_sekce = f"\n🌐 Top odkazy měsíce:\n\n{link_lines}"
|
||||||
|
else:
|
||||||
|
links_sekce = ""
|
||||||
|
|
||||||
return (
|
return (
|
||||||
f"🐘 Měsíční přehled Mamutovo.cz\n"
|
f"🐘 Měsíční přehled Mamutovo.cz\n"
|
||||||
f"📅 {format_month_cs(date_to)}\n"
|
f"📅 {format_month_cs(date_to)}\n"
|
||||||
@@ -181,6 +190,7 @@ def build_monthly_toot(measures_data, tags, top_tooty, date_to, prev_stats, inst
|
|||||||
f"\n"
|
f"\n"
|
||||||
f"{extra}"
|
f"{extra}"
|
||||||
f"{tooty_sekce}"
|
f"{tooty_sekce}"
|
||||||
|
f"{links_sekce}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def build_toot(measures_data, tags, top_tooty, date_from, date_to, week_number,
|
def build_toot(measures_data, tags, top_tooty, date_from, date_to, week_number,
|
||||||
@@ -397,9 +407,10 @@ def main():
|
|||||||
total_count = load_total_count_from_data(date_to, 30)
|
total_count = load_total_count_from_data(date_to, 30)
|
||||||
top_author = load_top_author_from_data(date_to, 30)
|
top_author = load_top_author_from_data(date_to, 30)
|
||||||
newest_account = load_newest_account_from_data(date_to, 30)
|
newest_account = load_newest_account_from_data(date_to, 30)
|
||||||
|
top_links = load_top_links_from_data(date_to, 30)
|
||||||
toot = build_monthly_toot(
|
toot = build_monthly_toot(
|
||||||
measures_data, tags, top_tooty, date_to, prev_stats, instance_info,
|
measures_data, tags, top_tooty, date_to, prev_stats, instance_info,
|
||||||
total_count, top_author, newest_account,
|
total_count, top_author, newest_account, top_links,
|
||||||
)
|
)
|
||||||
|
|
||||||
if args.dry_run:
|
if args.dry_run:
|
||||||
|
|||||||
Reference in New Issue
Block a user