Skip to content

Commit

Permalink
Fix: Batch deletion not recognised
Browse files Browse the repository at this point in the history
  • Loading branch information
slaurenz committed Feb 25, 2022
1 parent 8e40305 commit caf53ad
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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$;
Expand Down
8 changes: 5 additions & 3 deletions src/main/resources/db/sql/009_create_coordinate_view.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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));

Expand Down
11 changes: 6 additions & 5 deletions src/main/resources/db/sql/010_create_kid_view.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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])
)
Expand All @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions src/main/resources/db/sql/011_create_point_view.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
8 changes: 5 additions & 3 deletions src/main/resources/db/sql/012_create_vector_view.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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));

Expand Down

0 comments on commit caf53ad

Please sign in to comment.