Skip to content

Commit

Permalink
handle realtaed loggers
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokant committed Jun 14, 2024
1 parent 64b2b4b commit a45f829
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions db/migrations/20240508145818_related_loggers.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
-- migrate:up
DROP VIEW flat_logger_files;

CREATE VIEW flat_logger_files AS (
WITH has_logger_type AS (
SELECT
r.id,
array_agg(DISTINCT l."type") AS types,
li.deployment
FROM
ring AS r
JOIN logger_instrumentation AS li ON li.ring = r.id
JOIN logger AS l ON li.logger = l.id
GROUP BY
r.id,
li.deployment
)
SELECT
li.id,
li.logger,
h.types AS related_logger_types,
li.ring,
li.status,
li.sampling_freq_s,
li.mass_g,
li.attachment_method,
li.mount_method,
li.startup,
li.deployment,
li.retrieval,
li.filename,
li.data_stored_externally,
li.comment,
l.type,
l.model
FROM
logger_instrumentation li
JOIN has_logger_type h ON h.id = li.ring
AND h.deployment = li.deployment
JOIN logger l ON li.logger = l.id
);

GRANT SELECT ON public.flat_logger_files TO readonly;

-- migrate:down

0 comments on commit a45f829

Please sign in to comment.