fixed search query
This commit is contained in:
parent
13c5866884
commit
cc284b2612
@ -19,12 +19,13 @@ def GetShipcalls(options):
|
|||||||
|
|
||||||
pooledConnection = local_db.getPoolConnection()
|
pooledConnection = local_db.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, "
|
||||||
|
"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, created, modified FROM shipcall WHERE ((type = 1 OR type = 2) AND eta >= DATE(NOW() - INTERVAL %d DAY)"
|
||||||
|
"OR (type = 3 AND etd >= DATE(NOW() - INTERVAL %d DAY)) "
|
||||||
|
"ORDER BY eta") % (options["past_days"], options["past_days"])
|
||||||
|
|
||||||
data = commands.query("SELECT id, ship_id, type, eta, voyage, etd, arrival_berth_id, departure_berth_id, tug_required, pilot_required, " +
|
data = commands.query(query, model=model.Shipcall)
|
||||||
"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, created, modified FROM shipcall WHERE ((type = 1 OR type = 2) AND eta >= DATE(NOW() - INTERVAL %d DAY) " % (options["past_days"]) +
|
|
||||||
"OR (type = 3 AND etd >= DATE(NOW() - INTERVAL %d DAY)) " % (options["past_days"]) +
|
|
||||||
"ORDER BY eta" , model=model.Shipcall)
|
|
||||||
for shipcall in data:
|
for shipcall in data:
|
||||||
participant_query = "SELECT participant_id, type FROM shipcall_participant_map WHERE shipcall_id=?shipcall_id?";
|
participant_query = "SELECT participant_id, type FROM shipcall_participant_map WHERE shipcall_id=?shipcall_id?";
|
||||||
for record in commands.query(participant_query, model=dict, param={"shipcall_id" : shipcall.id}, buffered=False):
|
for record in commands.query(participant_query, model=dict, param={"shipcall_id" : shipcall.id}, buffered=False):
|
||||||
|
|||||||
Reference in New Issue
Block a user