From 34586d0281ae079bcad8f11859e86d890ce0e50d Mon Sep 17 00:00:00 2001 From: Bhupesh-V Date: Wed, 27 Dec 2023 13:02:03 +0530 Subject: [PATCH] add count of total posts in wiki --- community-threads-grabber/main.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/community-threads-grabber/main.py b/community-threads-grabber/main.py index 0bc02e7..8b82537 100644 --- a/community-threads-grabber/main.py +++ b/community-threads-grabber/main.py @@ -55,8 +55,13 @@ def update_wiki(reddit, wikipage, posts): for year in posts_by_year: posts_by_year[year] = sorted(posts_by_year[year], key=lambda k: k['created_at'], reverse=True) + # Calculate total posts and years + total_posts = sum(len(posts) for posts in posts_by_year.values()) + total_years = len(posts_by_year) + wiki_header = """# A collection of must read discussions started by community members""" content = wiki_header + "\n\n" + content += f"This collection contains a list of `{total_posts}` handpicked posts across `{total_years}` years.\n\n" for year in sorted(posts_by_year.keys(), reverse=True): content += f"## {year}\n\n"