firstroundgetquery

This commit is contained in:
Michael McGuinness
2025-01-03 10:35:42 +00:00
parent 382e01052f
commit 0ac156f0e1
6 changed files with 144 additions and 11 deletions
+13 -1
View File
@@ -1,2 +1,14 @@
-- name: GetQueryConfig :one
SELECT id, config FROM queryConfigs where queryId = $1 and addedVersion >= $2 and COALESCE(removedVersion, $2 - 1) < $2;
SELECT id, config FROM queryConfigs where queryId = $1 and addedVersion >= $2 and COALESCE(removedVersion, $2 - 1) < $2;
-- name: GetQuery :one
SELECT q.id, q.type, q.activeVersion, c.config, ARRAY_AGG(r.requiredQueryId) AS requiredIds
FROM queries AS q
JOIN queryConfigs AS c ON q.id = c.queryId
JOIN requiredQueries AS r ON q.id = r.queryId
WHERE q.id = $1
and c.addedVersion >= q.activeVersion
and COALESCE(c.removedVersion, q.activeVersion - 1) < q.activeVersion
and r.addedVersion >= q.activeVersion
and COALESCE(r.removedVersion, q.activeVersion - 1) < q.activeVersion
GROUP BY q.id, c.config;