From caf53ad1d64f302082e9f7284bbb0143eaeb48aa Mon Sep 17 00:00:00 2001 From: slaurenz <82034561+slaurenz@users.noreply.github.com> Date: Fri, 25 Feb 2022 17:50:30 +0100 Subject: [PATCH] Fix: Batch deletion not recognised --- .../sql/003_create_last_updated_trigger_function.sql | 2 +- .../resources/db/sql/009_create_coordinate_view.sql | 8 +++++--- src/main/resources/db/sql/010_create_kid_view.sql | 11 ++++++----- src/main/resources/db/sql/011_create_point_view.sql | 8 +++++--- src/main/resources/db/sql/012_create_vector_view.sql | 8 +++++--- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/main/resources/db/sql/003_create_last_updated_trigger_function.sql b/src/main/resources/db/sql/003_create_last_updated_trigger_function.sql index c46806b..dc153e7 100644 --- a/src/main/resources/db/sql/003_create_last_updated_trigger_function.sql +++ b/src/main/resources/db/sql/003_create_last_updated_trigger_function.sql @@ -10,7 +10,7 @@ CREATE OR REPLACE FUNCTION public.set_last_updated_function() AS $BODY$ BEGIN NEW.last_updated := NOW(); - + NEW.updated := true; RETURN NEW; END; $BODY$; diff --git a/src/main/resources/db/sql/009_create_coordinate_view.sql b/src/main/resources/db/sql/009_create_coordinate_view.sql index 7c51f07..17a9464 100644 --- a/src/main/resources/db/sql/009_create_coordinate_view.sql +++ b/src/main/resources/db/sql/009_create_coordinate_view.sql @@ -5,9 +5,10 @@ CREATE OR REPLACE VIEW public.coordinate_view AS SELECT row_number() OVER ()::text AS row_id, - case when hashes.kid isNull then 'UNKNOWN_KID' - else hashes.kid - END as kid, + CASE + WHEN hashes.kid IS NULL THEN 'UNKNOWN_KID'::character varying + ELSE hashes.kid + END AS kid, max(date_trunc('minute'::text, batch_list.expires))::timestamp with time zone AS expired, max(hashes.last_updated) AS lastupdated, array_agg(DISTINCT hashes.hash) AS hashes, @@ -17,6 +18,7 @@ CREATE OR REPLACE VIEW public.coordinate_view hashes.y::text AS y FROM hashes LEFT JOIN batch_list ON hashes.batch_id::text = batch_list.batch_id::text + WHERE hashes.batch_id IS NOT NULL GROUP BY hashes.kid, hashes.x, hashes.y, hashes.z, (date_trunc('minute'::text, batch_list.expires)) ORDER BY hashes.kid, (concat(hashes.x, hashes.y)), (hashes.z::text), (date_trunc('minute'::text, batch_list.expires)); diff --git a/src/main/resources/db/sql/010_create_kid_view.sql b/src/main/resources/db/sql/010_create_kid_view.sql index a34b251..d7d7d46 100644 --- a/src/main/resources/db/sql/010_create_kid_view.sql +++ b/src/main/resources/db/sql/010_create_kid_view.sql @@ -12,8 +12,8 @@ CREATE OR REPLACE VIEW public.kid_view WHEN configuration_1.key = 'COORDINATELIMIT'::text THEN 'COORDINATE'::text ELSE NULL::text END AS storage_mode, - to_number(configuration_1.value, '999999999999'::text) AS minlimit, - to_number(configuration_1.value2, '999999999999'::text) AS maxlimit + to_number(configuration_1.value, '999999999999'::text) AS minlimit, + to_number(configuration_1.value2, '999999999999'::text) AS maxlimit FROM public.configuration configuration_1 WHERE configuration_1.key = ANY (ARRAY['POINTLIMIT'::text, 'VECTORLIMIT'::text, 'COORDINATELIMIT'::text]) ) @@ -24,9 +24,10 @@ CREATE OR REPLACE VIEW public.kid_view a.expired, a.updated FROM ( SELECT - case when hashes.kid isNull then 'UNKNOWN_KID' - else hashes.kid - END as kid, + CASE + WHEN hashes.kid IS NULL THEN 'UNKNOWN_KID'::character varying + ELSE hashes.kid + END AS kid, count(*) AS c, array_to_string(array_agg(DISTINCT batch_list.type), ','::text) AS hashtypes, bool_or(hashes.updated) AS updated, diff --git a/src/main/resources/db/sql/011_create_point_view.sql b/src/main/resources/db/sql/011_create_point_view.sql index d771024..af9f18d 100644 --- a/src/main/resources/db/sql/011_create_point_view.sql +++ b/src/main/resources/db/sql/011_create_point_view.sql @@ -5,9 +5,10 @@ CREATE OR REPLACE VIEW public.point_view AS SELECT row_number() OVER ()::text AS row_id, - case when hashes.kid isNull then 'UNKNOWN_KID' - else hashes.kid - END as kid, + CASE + WHEN hashes.kid IS NULL THEN 'UNKNOWN_KID'::character varying + ELSE hashes.kid + END AS kid, max(date_trunc('minute'::text, batch_list.expires))::timestamp with time zone AS expired, max(hashes.last_updated) AS lastupdated, array_agg(DISTINCT hashes.hash) AS hashes, @@ -17,6 +18,7 @@ CREATE OR REPLACE VIEW public.point_view NULL::text AS y FROM hashes LEFT JOIN batch_list ON hashes.batch_id::text = batch_list.batch_id::text + WHERE hashes.batch_id IS NOT NULL GROUP BY hashes.kid, hashes.x, (date_trunc('minute'::text, batch_list.expires)); ALTER TABLE public.point_view diff --git a/src/main/resources/db/sql/012_create_vector_view.sql b/src/main/resources/db/sql/012_create_vector_view.sql index 79eea00..4a4b50f 100644 --- a/src/main/resources/db/sql/012_create_vector_view.sql +++ b/src/main/resources/db/sql/012_create_vector_view.sql @@ -5,9 +5,10 @@ CREATE OR REPLACE VIEW public.vector_view AS SELECT row_number() OVER ()::text AS row_id, - case when hashes.kid isNull then 'UNKNOWN_KID' - else hashes.kid - END as kid, + CASE + WHEN hashes.kid IS NULL THEN 'UNKNOWN_KID'::character varying + ELSE hashes.kid + END AS kid, max(date_trunc('minute'::text, batch_list.expires))::timestamp with time zone AS expired, max(hashes.last_updated) AS lastupdated, array_agg(DISTINCT hashes.hash) AS hashes, @@ -17,6 +18,7 @@ CREATE OR REPLACE VIEW public.vector_view NULL::text AS y FROM hashes LEFT JOIN batch_list ON hashes.batch_id::text = batch_list.batch_id::text + WHERE hashes.batch_id IS NOT NULL GROUP BY hashes.kid, hashes.x, hashes.y, (date_trunc('minute'::text, batch_list.expires)) ORDER BY hashes.kid, (hashes.x::text), NULL::text, (date_trunc('minute'::text, batch_list.expires));