diff --git a/changedetectionio/__init__.py b/changedetectionio/__init__.py index a5087e19..ed838ca6 100644 --- a/changedetectionio/__init__.py +++ b/changedetectionio/__init__.py @@ -178,6 +178,10 @@ def changedetection_app(config=None, datastore_o=None): global datastore datastore = datastore_o + # so far just for read-only via tests, but this will be moved eventually to be the main source + # (instead of the global var) + app.config['DATASTORE']=datastore_o + #app.config.update(config or {}) login_manager = flask_login.LoginManager(app) @@ -317,25 +321,19 @@ def changedetection_app(config=None, datastore_o=None): for watch in sorted_watches: - dates = list(watch['history'].keys()) + dates = list(watch.history.keys()) # Re #521 - Don't bother processing this one if theres less than 2 snapshots, means we never had a change detected. if len(dates) < 2: continue - # Convert to int, sort and back to str again - # @todo replace datastore getter that does this automatically - dates = [int(i) for i in dates] - dates.sort(reverse=True) - dates = [str(i) for i in dates] - prev_fname = watch['history'][dates[1]] + prev_fname = watch.history[dates[-2]] - if not watch['viewed']: + if not watch.viewed: # Re #239 - GUID needs to be individual for each event # @todo In the future make this a configurable link back (see work on BASE_URL https://github.com/dgtlmoon/changedetection.io/pull/228) guid = "{}/{}".format(watch['uuid'], watch['last_changed']) fe = fg.add_entry() - # Include a link to the diff page, they will have to login here to see if password protection is enabled. # Description is the page you watch, link takes you to the diff JS UI page base_url = datastore.data['settings']['application']['base_url'] @@ -350,13 +348,13 @@ def changedetection_app(config=None, datastore_o=None): watch_title = watch.get('title') if watch.get('title') else watch.get('url') fe.title(title=watch_title) - latest_fname = watch['history'][dates[0]] + latest_fname = watch.history[dates[-1]] html_diff = diff.render_diff(prev_fname, latest_fname, include_equal=False, line_feed_sep="") fe.description(description="