[fix] reminding notifications
This commit is contained in:
parent
ad0dbb2a5d
commit
d3028549cf
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue