From d3028549cfb6d0f5b38f52c2731a85f1e99e5082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Fra=C3=9F?= Date: Fri, 23 Jun 2023 12:55:17 +0200 Subject: [PATCH 1/3] [fix] reminding notifications --- source/logic/main.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/source/logic/main.py b/source/logic/main.py index c024e25..52eea7f 100644 --- a/source/logic/main.py +++ b/source/logic/main.py @@ -204,7 +204,14 @@ def main(): pass else: ### get old state and examine whether the check shall be executed - rows = sqlite_query_get( + rows1 = sqlite_query_get( + database_path, + "SELECT MIN(timestamp) FROM results WHERE (check_name = :check_name) AND (notification_sent = TRUE);", + { + "check_name": check_data["name"], + } + ) + rows2 = sqlite_query_get( database_path, "SELECT timestamp, condition, notification_sent FROM results WHERE (check_name = :check_name) ORDER BY timestamp DESC LIMIT :limit;", { @@ -212,13 +219,12 @@ def main(): "limit": (check_data["threshold"] + 1), } ) - if (len(rows) <= 0): + if (len(rows2) <= 0): old_item_state = None else: - last_notification_timestamp = None count = 1 - for row in rows[1:]: - if (row[1] == rows[0][1]): + for row in rows2[1:]: + if (row[1] == rows2[0][1]): count += 1 else: break @@ -226,17 +232,11 @@ def main(): count = None else: pass - for row in rows: - if (row[2]): - last_notification_timestamp = row[0] - break - else: - pass old_item_state = { - "timestamp": rows[0][0], - "condition": condition_decode(rows[0][1]), + "timestamp": rows2[0][0], + "condition": condition_decode(rows2[0][1]), "count": count, - "last_notification_timestamp": last_notification_timestamp, + "last_notification_timestamp": rows1[0][0], } timestamp = get_current_timestamp() From 5c7b3fc81934bfbd5a014b4c2a3dc63d60c35bda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Fra=C3=9F?= Date: Fri, 23 Jun 2023 13:50:58 +0200 Subject: [PATCH 2/3] [fix] reminding notifications --- source/logic/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/logic/main.py b/source/logic/main.py index 52eea7f..1f89705 100644 --- a/source/logic/main.py +++ b/source/logic/main.py @@ -206,7 +206,7 @@ def main(): ### get old state and examine whether the check shall be executed rows1 = sqlite_query_get( database_path, - "SELECT MIN(timestamp) FROM results WHERE (check_name = :check_name) AND (notification_sent = TRUE);", + "SELECT MAX(timestamp) FROM results WHERE (check_name = :check_name) AND (notification_sent = TRUE);", { "check_name": check_data["name"], } @@ -378,7 +378,7 @@ def main(): ) ) - if (not _os.exists(args.mutex_path)): + if (not _os.path.exists(args.mutex_path)): pass else: _os.remove(args.mutex_path) From 0df0862625acc227c995e475821d4de43f306ff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Fra=C3=9F?= Date: Mon, 3 Jul 2023 10:32:23 +0200 Subject: [PATCH 3/3] [mod] localization --- source/localization/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/localization/en.json b/source/localization/en.json index 7135b00..700515d 100644 --- a/source/localization/en.json +++ b/source/localization/en.json @@ -25,7 +25,7 @@ "checks.http_request.request_failed": "HTTP request failed", "checks.http_request.status_code_mismatch": "actual status code {{status_code_actual}} does not match expected value {{status_code_expected}}", "checks.http_request.header_missing": "header '{{key}}' is unset and hence does not match the expected value '{{value_expected}}'", - "checks.http_request.header_value_mismatch": "actual header value for key '{{key}}' '{{value_actual}}' and does not match the expected value {{value_expected}}", + "checks.http_request.header_value_mismatch": "actual header value for key '{{key}}' '{{value_actual}}' does not match the expected value {{value_expected}}", "checks.http_request.body_misses_part": "body does not contain the expected part '{{part}}'", "misc.state_file_path": "state file path", "misc.check_procedure_failed": "check procedure failed",