From d07cf53a07e6a22f897d3a139c52742f0f294ebc Mon Sep 17 00:00:00 2001 From: Leigh Morresi <275001+dgtlmoon@users.noreply.github.com> Date: Thu, 4 Feb 2021 13:15:39 +0100 Subject: [PATCH] Minor fix to 'last changed' field, simplify template and logic --- backend/backend.py | 2 -- backend/fetch_site_status.py | 4 ++-- backend/templates/watch-overview.html | 7 ++++++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/backend/backend.py b/backend/backend.py index 47e305a0..b3563808 100644 --- a/backend/backend.py +++ b/backend/backend.py @@ -76,8 +76,6 @@ def _jinja2_filter_datetime(watch_obj, format="%Y-%m-%d %H:%M:%S"): @app.template_filter('format_timestamp_timeago') def _jinja2_filter_datetimestamp(timestamp, format="%Y-%m-%d %H:%M:%S"): - if timestamp == 0: - return 'Not yet' return timeago.format(timestamp, time.time()) # return timeago.format(timestamp, time.time()) # return datetime.datetime.utcfromtimestamp(timestamp).strftime(format) diff --git a/backend/fetch_site_status.py b/backend/fetch_site_status.py index 4b41d8c5..95b75a8a 100644 --- a/backend/fetch_site_status.py +++ b/backend/fetch_site_status.py @@ -113,10 +113,10 @@ class perform_site_check(): fetched_md5 = hashlib.md5(stripped_text_from_html.encode('utf-8')).hexdigest() - if self.current_md5 != fetched_md5: + if self.current_md5 != fetched_md5: # could be None or False depending on JSON type # Don't confuse people by updating as last-changed, when it actually just changed from None.. - if self.datastore.get_val(self.uuid, 'previous_md5') is not None: + if self.datastore.get_val(self.uuid, 'previous_md5'): self.update_obj["last_changed"] = self.timestamp self.update_obj["previous_md5"] = fetched_md5 diff --git a/backend/templates/watch-overview.html b/backend/templates/watch-overview.html index 939343c8..7777bd36 100644 --- a/backend/templates/watch-overview.html +++ b/backend/templates/watch-overview.html @@ -53,7 +53,12 @@ {% endif %} {{watch|format_last_checked_time}} - {{watch.last_changed|format_timestamp_timeago}} + {% if watch.history|length >= 2 and watch.last_changed %} + {{watch.last_changed|format_timestamp_timeago}} + {% else %} + Not yet + {% endif %} + Recheck Edit {% if watch.history|length >= 2 %}