From c73b9efe9e951a05de1e9f21a08ed9255bdc6c3d Mon Sep 17 00:00:00 2001 From: Leigh Morresi <275001+dgtlmoon@users.noreply.github.com> Date: Wed, 27 Jan 2021 19:09:37 +0100 Subject: [PATCH] sort by last changed --- backend/backend.py | 4 ++++ backend/store.py | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/backend.py b/backend/backend.py index 816892b9..799fe552 100644 --- a/backend/backend.py +++ b/backend/backend.py @@ -80,6 +80,10 @@ def main_page(): # Show messages but once. # maybe if the change happened more than a few days ago.. add a class + + # Sort by last_changed + datastore.data['watching'].sort(key=lambda x: x['last_changed'], reverse=True) + output = render_template("watch-overview.html", watches=datastore.data['watching'], messages=messages) messages = [] return output diff --git a/backend/store.py b/backend/store.py index 5865143d..9d0bb4d2 100644 --- a/backend/store.py +++ b/backend/store.py @@ -13,7 +13,6 @@ class ChangeDetectionStore: try: with open('/datastore/url-watches.json') as json_file: self.data = json.load(json_file) - self.data['watching'].reverse() for p in self.data['watching']: print("Watching:", p['url'])