Minor fix to 'last changed' field, simplify template and logic

pull/11/head
Leigh Morresi 4 years ago
parent b9f73a6240
commit d07cf53a07

@ -76,8 +76,6 @@ def _jinja2_filter_datetime(watch_obj, format="%Y-%m-%d %H:%M:%S"):
@app.template_filter('format_timestamp_timeago') @app.template_filter('format_timestamp_timeago')
def _jinja2_filter_datetimestamp(timestamp, format="%Y-%m-%d %H:%M:%S"): 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 timeago.format(timestamp, time.time()) # return timeago.format(timestamp, time.time())
# return datetime.datetime.utcfromtimestamp(timestamp).strftime(format) # return datetime.datetime.utcfromtimestamp(timestamp).strftime(format)

@ -113,10 +113,10 @@ class perform_site_check():
fetched_md5 = hashlib.md5(stripped_text_from_html.encode('utf-8')).hexdigest() 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.. # 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["last_changed"] = self.timestamp
self.update_obj["previous_md5"] = fetched_md5 self.update_obj["previous_md5"] = fetched_md5

@ -53,7 +53,12 @@
{% endif %} {% endif %}
</td> </td>
<td>{{watch|format_last_checked_time}}</td> <td>{{watch|format_last_checked_time}}</td>
<td>{{watch.last_changed|format_timestamp_timeago}}</td> <td>{% if watch.history|length >= 2 and watch.last_changed %}
{{watch.last_changed|format_timestamp_timeago}}
{% else %}
Not yet
{% endif %}
</td>
<td><a href="/api/checknow?uuid={{ watch.uuid}}{% if request.args.get('tag') %}&tag={{request.args.get('tag')}}{% endif %}" class="pure-button button-small pure-button-primary">Recheck</a> <td><a href="/api/checknow?uuid={{ watch.uuid}}{% if request.args.get('tag') %}&tag={{request.args.get('tag')}}{% endif %}" class="pure-button button-small pure-button-primary">Recheck</a>
<a href="/edit?uuid={{ watch.uuid}}" class="pure-button button-small pure-button-primary">Edit</a> <a href="/edit?uuid={{ watch.uuid}}" class="pure-button button-small pure-button-primary">Edit</a>
{% if watch.history|length >= 2 %} {% if watch.history|length >= 2 %}

Loading…
Cancel
Save