2025-01-08 18:14:15 +00:00
|
|
|
CREATE VIEW fullActiveQueries AS
|
2025-01-20 13:31:48 +00:00
|
|
|
SELECT DISTINCT q.id, q.type, q.activeVersion, q.latestVersion, coalesce(c.config, null) as config, ARRAY_AGG(DISTINCT r.requiredQueryId)::uuid[] as requiredIds
|
2025-01-08 18:14:15 +00:00
|
|
|
FROM queries AS q
|
|
|
|
|
LEFT JOIN queryConfigs AS c ON q.id = c.queryId
|
2025-01-21 12:28:46 +00:00
|
|
|
and q.activeVersion >= c.addedVersion
|
|
|
|
|
and q.activeVersion < COALESCE(c.removedVersion, q.activeVersion + 1)
|
2025-01-08 18:14:15 +00:00
|
|
|
LEFT JOIN requiredQueries AS r ON q.id = r.queryId
|
2025-01-21 12:28:46 +00:00
|
|
|
and q.activeVersion >= r.addedVersion
|
|
|
|
|
and q.activeVersion < COALESCE(r.removedVersion, q.activeVersion + 1)
|
2025-01-20 13:31:48 +00:00
|
|
|
GROUP BY q.id, q.type, q.activeversion, q.latestversion, c.config;
|