From b1501f8aad6ba48cfce1368e16cfa190f87567b6 Mon Sep 17 00:00:00 2001 From: dominicwest Date: Mon, 1 Apr 2024 15:20:14 +0100 Subject: [PATCH] GAP-2533: Fix advert scheduler view for BST --- ...eduled_publishing_daylight_savings_fix.sql | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/main/resources/db/migration/V1_99__scheduled_publishing_daylight_savings_fix.sql diff --git a/src/main/resources/db/migration/V1_99__scheduled_publishing_daylight_savings_fix.sql b/src/main/resources/db/migration/V1_99__scheduled_publishing_daylight_savings_fix.sql new file mode 100644 index 00000000..befb053f --- /dev/null +++ b/src/main/resources/db/migration/V1_99__scheduled_publishing_daylight_savings_fix.sql @@ -0,0 +1,21 @@ +-- Replace view for scheduler + +DROP VIEW IF EXISTS ADVERT_SCHEDULER_VIEW; +CREATE VIEW ADVERT_SCHEDULER_VIEW AS +SELECT GRANT_ADVERT_ID AS ID, + CASE + WHEN + STATUS = 'SCHEDULED' + AND (OPENING_DATE AT TIME ZONE 'Europe/London') <= NOW() AT TIME ZONE 'Europe/London' + THEN 'PUBLISH' + WHEN + STATUS = 'PUBLISHED' + AND (CLOSING_DATE AT TIME ZONE 'Europe/London') <= NOW() AT TIME ZONE 'Europe/London' + THEN 'UNPUBLISH' + END AS ACTION +FROM GRANT_ADVERT +WHERE ( + STATUS = 'SCHEDULED' AND (OPENING_DATE AT TIME ZONE 'Europe/London') <= NOW() AT TIME ZONE 'Europe/London' +) OR ( + STATUS = 'PUBLISHED' AND (CLOSING_DATE AT TIME ZONE 'Europe/London') <= (NOW() AT TIME ZONE 'Europe/London') +); \ No newline at end of file