From d180dac600dc87174ce7396fff971475b9a75c04 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Fri, 14 Mar 2025 15:03:38 +0100 Subject: [PATCH] improved next 24hr schedule check query that takes precedence for times eta value --- src/server/BreCal/database/sql_queries.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/server/BreCal/database/sql_queries.py b/src/server/BreCal/database/sql_queries.py index 47e4bfa..62fe49d 100644 --- a/src/server/BreCal/database/sql_queries.py +++ b/src/server/BreCal/database/sql_queries.py @@ -281,10 +281,8 @@ class SQLQuery(): def get_next24hrs_shipcalls()->str: query = ("SELECT s.id as id, ship.name as name FROM shipcall s INNER JOIN ship ON s.ship_id = ship.id 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 >= NOW() AND t.eta_berth < (NOW() + INTERVAL 1 DAY))" + \ - "OR (eta >= NOW() AND eta < (NOW() + INTERVAL 1 DAY)))) OR " + \ - "((type = 2 OR type = 3) AND ((t.id IS NOT NULL AND t.etd_berth >= NOW() AND " + \ - "t.etd_berth < (NOW() + INTERVAL 1 DAY)) OR (etd >= NOW() AND etd < (NOW() + INTERVAL 1 DAY))))" + \ + "WHERE (type = 1 AND (COALESCE(t.eta_berth, eta) >= NOW() AND COALESCE(t.eta_berth, eta) < (NOW() + INTERVAL 1 DAY)))" + \ + "OR ((type = 2 OR type = 3) AND (COALESCE(t.etd_berth, etd) >= NOW() AND COALESCE(t.etd_berth, etd) < (NOW() + INTERVAL 1 DAY)))" "AND s.canceled = 0") return query