From a03e53d8269189928e71057df74c380459d5d289 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Thu, 27 May 2021 23:55:05 +1000 Subject: [PATCH] Re #40 Ability to set individual timers (#72) * Re #40 Ability to set individual timers --- backend/__init__.py | 18 ++++++++++++++++++ backend/store.py | 1 + backend/templates/edit.html | 7 +++++++ backend/templates/settings.html | 3 ++- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/backend/__init__.py b/backend/__init__.py index c2e77b4b..96c26040 100644 --- a/backend/__init__.py +++ b/backend/__init__.py @@ -334,6 +334,17 @@ def changedetection_app(conig=None, datastore_o=None): url = request.form.get('url').strip() tag = request.form.get('tag').strip() + minutes_recheck = request.form.get('minutes') + if minutes_recheck: + minutes = int(minutes_recheck.strip()) + if minutes >= 1: + datastore.data['watching'][uuid]['minutes_between_check'] = minutes + else: + messages.append( + {'class': 'error', 'message': "Must be atleast 1 minute."}) + + + # Extra headers form_headers = request.form.get('headers').strip().split("\n") extra_headers = {} @@ -856,9 +867,16 @@ def ticker_thread_check_time_launch_checks(): threshold = time.time() - (minutes * 60) for uuid, watch in datastore.data['watching'].items(): + + # If they supplied an individual entry minutes to recheck and its not the same as the default + if 'minutes_between_check' in watch and minutes != watch['minutes_between_check']: + threshold = time.time() - (watch['minutes_between_check'] * 60) + if not watch['paused'] and watch['last_checked'] <= threshold: if not uuid in running_uuids and uuid not in update_q.queue: update_q.put(uuid) + time.sleep(1) + # Should be low so we can break this out in testing app.config.exit.wait(1) diff --git a/backend/store.py b/backend/store.py index 34e4938b..784e1029 100644 --- a/backend/store.py +++ b/backend/store.py @@ -55,6 +55,7 @@ class ChangeDetectionStore: 'last_viewed': 0, # history key value of the last viewed via the [diff] link 'newest_history_key': "", 'title': None, + 'minutes_between_check': 3 * 60, # Default 3 hours 'previous_md5': "", 'uuid': str(uuid_builder.uuid4()), 'headers': {}, # Extra headers to send diff --git a/backend/templates/edit.html b/backend/templates/edit.html index f889cf8c..14e109d7 100644 --- a/backend/templates/edit.html +++ b/backend/templates/edit.html @@ -17,6 +17,13 @@ Grouping tags, can be a comma separated list. +
+
+ + + Minimum 1 minute between recheck +
diff --git a/backend/templates/settings.html b/backend/templates/settings.html index fec14a4b..435909d8 100644 --- a/backend/templates/settings.html +++ b/backend/templates/settings.html @@ -10,7 +10,8 @@ - This is a required field. + This is a required field.
+ Minimum 1 minute between recheck