From 74724efc8a45be4c0d7ca1b06b537709e538a886 Mon Sep 17 00:00:00 2001 From: berrysauce Date: Sat, 10 Jul 2021 16:57:01 +0200 Subject: [PATCH] Now sorting posts and subscribers by date --- tools/htmlgen.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/htmlgen.py b/tools/htmlgen.py index 42e0230..6244753 100644 --- a/tools/htmlgen.py +++ b/tools/htmlgen.py @@ -15,6 +15,8 @@ def postcode(): if len(entries) == 0: posts_html = """

You have no posts

""" else: + entries.sort(key = lambda x:x["date"]) + entries = entries[::-1] posts_html = """""" with open("templates/elements/post_card.html", "r") as f: posts_html_template = jinja2.Template(f.read()) @@ -35,6 +37,10 @@ def subscribertable(): monthly_subscribers = 0 table_html = """""" + if len(entries) != 0: + entries.sort(key = lambda x:x["subscribed_on"]) + entries = entries[::-1] + for entry in entries: if month in entry["subscribed_on"]: monthly_subscribers += 1