feat: nejdiskutovanější toot podle počtu odpovědí

This commit is contained in:
2026-06-20 07:03:49 +02:00
parent 742b23b064
commit ab3833f5a2
2 changed files with 57 additions and 3 deletions
+14
View File
@@ -108,12 +108,14 @@ def main():
tag_counts[name] = tag_counts.get(name, 0) + 1
reblogs = toot.get("reblogs_count", 0)
favourites = toot.get("favourites_count", 0)
replies = toot.get("replies_count", 0)
candidates.append({
"acct": toot["account"]["acct"],
"text": text,
"url": toot.get("url", ""),
"reblogs": reblogs,
"favourites": favourites,
"replies": replies,
"score": reblogs + favourites,
})
@@ -121,6 +123,17 @@ def main():
top = candidates[:3]
tags = [t for t, _ in sorted(tag_counts.items(), key=lambda x: x[1], reverse=True)[:5]]
most_discussed = None
if candidates:
md = max(candidates, key=lambda x: x["replies"])
if md["replies"] > 0:
most_discussed = {
"acct": md["acct"],
"text": md["text"],
"url": md["url"],
"replies": md["replies"],
}
authors_count = {}
for c in candidates:
authors_count[c["acct"]] = authors_count.get(c["acct"], 0) + 1
@@ -162,6 +175,7 @@ def main():
"authors_count": authors_count,
"newest_account": newest_account,
"top": top,
"most_discussed": most_discussed,
"tags": tags,
"top_links": top_links,
"media_count": media_count,