fixes for errors reported in server log

This commit is contained in:
Daniel Schick 2024-02-14 15:41:21 +01:00
parent 898cfdf07d
commit 8a6ded2813
4 changed files with 12 additions and 7 deletions

View File

@ -113,10 +113,11 @@ def PostShipcalls(schemaModel):
commands.execute(query, schemaModel)
new_id = commands.execute_scalar("select last_insert_id()")
# add participant assignments
pquery = "INSERT INTO shipcall_participant_map (shipcall_id, participant_id, type) VALUES (?shipcall_id?, ?participant_id?, ?type?)"
for participant_assignment in schemaModel["participants"]:
commands.execute(pquery, param={"shipcall_id" : new_id, "participant_id" : participant_assignment["participant_id"], "type" : participant_assignment["type"]})
# add participant assignments if we have a list of participants
if 'participants' in schemaModel:
pquery = "INSERT INTO shipcall_participant_map (shipcall_id, participant_id, type) VALUES (?shipcall_id?, ?participant_id?, ?type?)"
for participant_assignment in schemaModel["participants"]:
commands.execute(pquery, param={"shipcall_id" : new_id, "participant_id" : participant_assignment["participant_id"], "type" : participant_assignment["type"]})
# apply 'Traffic Light' evaluation to obtain 'GREEN', 'YELLOW' or 'RED' evaluation state. The function internally updates the mysql database
# evaluate_shipcall_state(mysql_connector_instance=pooledConnection, shipcall_id=new_id) # new_id (last insert id) refers to the shipcall id

View File

@ -256,6 +256,10 @@ class User:
user_phone: str
password_hash: str
api_key: str
notify_email: bool
notify_whatsapp: bool
notify_signal: bool
notify_popup: bool
created: datetime
modified: datetime

View File

@ -27,7 +27,7 @@ def UpdateShipcalls(options:dict = {'past_days':2}):
commands = pydapper.using(pooledConnection)
query = ("SELECT id, ship_id, type, eta, voyage, etd, arrival_berth_id, departure_berth_id, tug_required, pilot_required, "
"flags, pier_side, bunkering, replenishing_terminal, replenishing_lock, draft, tidal_window_from, tidal_window_to, rain_sensitive_cargo, recommended_tugs, "
"anchored, moored_lock, canceled, evaluation, evaluation_message, evaluation_message_sent, evaluation_time, created, modified FROM shipcall WHERE ((type = 1 OR type = 3) AND eta >= DATE(NOW() - INTERVAL %d DAY)"
"anchored, moored_lock, canceled, evaluation, evaluation_message, evaluation_notifications_sent, evaluation_time, created, modified FROM shipcall WHERE ((type = 1 OR type = 3) AND eta >= DATE(NOW() - INTERVAL %d DAY)"
"OR (type = 2 AND etd >= DATE(NOW() - INTERVAL %d DAY))) "
"ORDER BY eta") % (options["past_days"], options["past_days"])

View File

@ -42,7 +42,7 @@ def get_shipcall_simple():
evaluation = None
evaluation_message = ""
evaluation_time = None
evaluation_message_sent = False
evaluation_notifications_sent = False
created = datetime.datetime.now()
modified = created+datetime.timedelta(seconds=10)
@ -75,7 +75,7 @@ def get_shipcall_simple():
evaluation,
evaluation_message,
evaluation_time,
evaluation_message_sent,
evaluation_notifications_sent,
created,
modified,
participants,