From 78404066886693e87171e904fb838bbbab508c25 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Mon, 13 Jan 2025 16:31:32 +0100 Subject: [PATCH] split up red / yellow evaluation errors on separate notification types (time_conflict(red), missing_data(yellow)) --- src/server/BreCal/validators/validation_rules.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/server/BreCal/validators/validation_rules.py b/src/server/BreCal/validators/validation_rules.py index 9b33fba..3cc5729 100644 --- a/src/server/BreCal/validators/validation_rules.py +++ b/src/server/BreCal/validators/validation_rules.py @@ -92,12 +92,14 @@ class ValidationRules(ValidationRuleFunctions): if evaluation_states_old[0] != evaluation_states_new[0]: pooledConnection = getPoolConnection() commands = pydapper.using(pooledConnection) + notification_type = 3 # RED (mapped to time_conflict) if evaluation_states_new[0] == 2: match evaluation_states_old[0]: case 0: send_notification = True case 1: send_notification = True + notification_type = 6 # YELLOW (mapped to missing_data) if evaluation_states_new[0] == 3: match evaluation_states_old[0]: case 0: @@ -108,11 +110,11 @@ class ValidationRules(ValidationRuleFunctions): send_notification = True if send_notification: - query = "INSERT INTO notification (shipcall_id, type, level, message) VALUES (?shipcall_id?, 3, 0, ?message?)" + query = f"INSERT INTO notification (shipcall_id, type, level, message) VALUES (?shipcall_id?, {notification_type}, 0, ?message?)" commands.execute(query, param={"shipcall_id" : int(shipcall_df.index[0]), "message" : violations[0]}) if evaluation_states_new[0] == 1 and evaluation_states_old[0] != 0: # this resolves the conflict - query = "SELECT * from notification where shipcall_id = ?shipcall_id? and type = 3 and level = 0" + query = f"SELECT * from notification where shipcall_id = ?shipcall_id? and type = {notification_type} and level = 0" existing_notification = commands.query(query, param={"shipcall_id" : int(shipcall_df.index[0])}) if len(existing_notification) > 0: query = "DELETE from notification where id = ?id?"