Modify log_midnight_shots() to remove non-relevant midnight shots.

Those shots could for instance have been removed to a line edit.
This commit is contained in:
D. Berge
2022-05-15 13:20:01 +02:00
parent bada6dc2e2
commit aff974c03f

View File

@@ -117,6 +117,20 @@ BEGIN
FROM event_log el
WHERE ms.sequence = el.sequence AND ms.point = el.point AND el.labels @> ms.labels
);
-- Delete any midnight shots that might have been inserted in the log
-- but are no longer relevant according to the final_shots data.
-- We operate on event_log, so the deletion is traceable.
DELETE
FROM event_log
WHERE id IN (
SELECT id
FROM event_log el
LEFT JOIN midnight_shots ms USING (sequence, point)
WHERE
'{LDSP,FDSP}'::text[] && el.labels -- &&: Do the arrays overlap?
AND ms.sequence IS NULL
);
$$;
COMMENT ON PROCEDURE log_midnight_shots (date, date)