improved sorting and using COALESCE instead of not null

This commit is contained in:
Daniel Schick 2024-04-29 11:32:45 +02:00
parent 3579d779e8
commit f690387be8

View File

@ -25,13 +25,9 @@ def GetShipcalls(options):
"FROM shipcall s " +
"LEFT JOIN times t ON t.shipcall_id = s.id AND t.participant_type = 8 " +
"WHERE " +
"(type = 1 AND " +
"((t.id IS NOT NULL AND t.eta_berth >= DATE(NOW() - INTERVAL %d DAY)) OR " +
"(eta >= DATE(NOW() - INTERVAL %d DAY)))) OR " +
"((type = 2 OR type = 3) AND " +
"((t.id IS NOT NULL AND t.etd_berth >= DATE(NOW() - INTERVAL %d DAY)) OR " +
"(etd >= DATE(NOW() - INTERVAL %d DAY)))) " +
"ORDER BY eta") % (options["past_days"], options["past_days"], options["past_days"], options["past_days"])
"(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"])
data = commands.query(query, model=model.Shipcall.from_query_row, buffered=True)
for shipcall in data:
@ -84,9 +80,9 @@ def PostShipcalls(schemaModel):
if key == "evaluation":
continue
if key == "evaluation_message":
continue
continue
if key == "type_value":
continue
continue
if key == "evaluation_value":
continue
if isNotFirst: