From f690387be80cb6c67636c5fd4d8e23e904e4bda0 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Mon, 29 Apr 2024 11:32:45 +0200 Subject: [PATCH] improved sorting and using COALESCE instead of not null --- src/server/BreCal/impl/shipcalls.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/server/BreCal/impl/shipcalls.py b/src/server/BreCal/impl/shipcalls.py index 915b345..111aee0 100644 --- a/src/server/BreCal/impl/shipcalls.py +++ b/src/server/BreCal/impl/shipcalls.py @@ -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: