set schedule logging to INFO and using correct query for schedule test calls
This commit is contained in:
parent
707ffd0d59
commit
3b01dbb7aa
@ -25,11 +25,15 @@ def UpdateShipcalls(options:dict = {'past_days':2}):
|
|||||||
try:
|
try:
|
||||||
pooledConnection = getPoolConnection()
|
pooledConnection = getPoolConnection()
|
||||||
commands = pydapper.using(pooledConnection)
|
commands = pydapper.using(pooledConnection)
|
||||||
|
|
||||||
query = ("SELECT id, ship_id, type, eta, voyage, etd, arrival_berth_id, departure_berth_id, tug_required, pilot_required, "
|
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, "
|
"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_notifications_sent, evaluation_time, created, modified, time_ref_point 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, time_ref_point FROM shipcall s " +
|
||||||
"OR (type = 2 AND etd >= DATE(NOW() - INTERVAL %d DAY))) "
|
"LEFT JOIN times t ON t.shipcall_id = s.id AND t.participant_type = 8 "
|
||||||
"ORDER BY eta") % (options["past_days"], options["past_days"])
|
"WHERE "
|
||||||
|
"(type = 1 AND (COALESCE(t.eta_berth, eta) >= DATE(NOW() - INTERVAL %d DAY))) OR "
|
||||||
|
"((type = 2 OR type = 3) AND (COALESCE(t.etd_berth, etd) >= DATE(NOW() - INTERVAL %d DAY)))"
|
||||||
|
"ORDER BY s.id") % (options["past_days"], options["past_days"])
|
||||||
|
|
||||||
# obtain data from the MYSQL database
|
# obtain data from the MYSQL database
|
||||||
data = commands.query(query, model=model.Shipcall)
|
data = commands.query(query, model=model.Shipcall)
|
||||||
@ -54,6 +58,9 @@ def add_function_to_schedule__update_shipcalls(interval_in_minutes:int, options:
|
|||||||
return
|
return
|
||||||
|
|
||||||
def setup_schedule(update_shipcalls_interval_in_minutes:int=60):
|
def setup_schedule(update_shipcalls_interval_in_minutes:int=60):
|
||||||
|
|
||||||
|
logging.getLogger('schedule').setLevel(logging.INFO); # set the logging level of the schedule module to INFO
|
||||||
|
|
||||||
schedule.clear() # clear all routine jobs. This prevents jobs from being created multiple times
|
schedule.clear() # clear all routine jobs. This prevents jobs from being created multiple times
|
||||||
|
|
||||||
# update the evaluation state in every recent shipcall
|
# update the evaluation state in every recent shipcall
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import copy
|
import copy
|
||||||
|
import logging
|
||||||
import re
|
import re
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
@ -52,6 +53,8 @@ class ValidationRules(ValidationRuleFunctions):
|
|||||||
# 'translate' all error codes into readable, human-understandable format.
|
# 'translate' all error codes into readable, human-understandable format.
|
||||||
evaluation_results = [(state, self.describe_error_message(msg)) for (state, msg) in evaluation_results]
|
evaluation_results = [(state, self.describe_error_message(msg)) for (state, msg) in evaluation_results]
|
||||||
|
|
||||||
|
logging.info(f"Validation results for shipcall {shipcall.id}: {evaluation_results}")
|
||||||
|
|
||||||
# check, what the maximum state flag is and return it
|
# check, what the maximum state flag is and return it
|
||||||
evaluation_state = np.max(np.array([result[0].value for result in evaluation_results])) if len(evaluation_results)>0 else StatusFlags.GREEN.value
|
evaluation_state = np.max(np.array([result[0].value for result in evaluation_results])) if len(evaluation_results)>0 else StatusFlags.GREEN.value
|
||||||
evaluation_verbosity = [result[1] for result in evaluation_results]
|
evaluation_verbosity = [result[1] for result in evaluation_results]
|
||||||
|
|||||||
Reference in New Issue
Block a user