split up red / yellow evaluation errors on separate notification types (time_conflict(red), missing_data(yellow))
This commit is contained in:
parent
1f860baa2b
commit
7840406688
@ -92,12 +92,14 @@ class ValidationRules(ValidationRuleFunctions):
|
|||||||
if evaluation_states_old[0] != evaluation_states_new[0]:
|
if evaluation_states_old[0] != evaluation_states_new[0]:
|
||||||
pooledConnection = getPoolConnection()
|
pooledConnection = getPoolConnection()
|
||||||
commands = pydapper.using(pooledConnection)
|
commands = pydapper.using(pooledConnection)
|
||||||
|
notification_type = 3 # RED (mapped to time_conflict)
|
||||||
if evaluation_states_new[0] == 2:
|
if evaluation_states_new[0] == 2:
|
||||||
match evaluation_states_old[0]:
|
match evaluation_states_old[0]:
|
||||||
case 0:
|
case 0:
|
||||||
send_notification = True
|
send_notification = True
|
||||||
case 1:
|
case 1:
|
||||||
send_notification = True
|
send_notification = True
|
||||||
|
notification_type = 6 # YELLOW (mapped to missing_data)
|
||||||
if evaluation_states_new[0] == 3:
|
if evaluation_states_new[0] == 3:
|
||||||
match evaluation_states_old[0]:
|
match evaluation_states_old[0]:
|
||||||
case 0:
|
case 0:
|
||||||
@ -108,11 +110,11 @@ class ValidationRules(ValidationRuleFunctions):
|
|||||||
send_notification = True
|
send_notification = True
|
||||||
|
|
||||||
if send_notification:
|
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]})
|
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
|
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])})
|
existing_notification = commands.query(query, param={"shipcall_id" : int(shipcall_df.index[0])})
|
||||||
if len(existing_notification) > 0:
|
if len(existing_notification) > 0:
|
||||||
query = "DELETE from notification where id = ?id?"
|
query = "DELETE from notification where id = ?id?"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user