Merged in feature/testwithlogs (pull request #65)

Query Version Sync Runner

* testing

* queryversiosyncworking

* update

* tests

* fixtests
This commit is contained in:
Michael McGuinness
2025-02-14 10:56:24 +00:00
parent 477518e5eb
commit 0df3d16976
91 changed files with 1737 additions and 624 deletions
+31 -9
View File
@@ -5,16 +5,35 @@ SELECT id, config FROM queryConfigs where queryId = $1 and addedVersion >= $2 an
SELECT * FROM fullActiveQueries WHERE id = $1;
-- name: GetQueryWithVersion :one
SELECT DISTINCT q.id, q.type, q.activeVersion, q.latestVersion, coalesce(c.config, null) as config, ARRAY_AGG(DISTINCT r.requiredQueryId)::uuid[] as requiredIds
FROM queries AS q
WITH query as (
SELECT id, type, activeVersion, latestVersion FROM queries WHERE id = @id
),
config as (
SELECT c.queryId, c.config
FROM query AS q
LEFT JOIN queryConfigs AS c ON q.id = c.queryId
and $2 >= c.addedVersion
and $2 < COALESCE(c.removedVersion, $2 + 1)
and @version >= c.addedVersion
and (c.removedVersion is null or @version < c.removedVersion)
),
requiredIds as (
SELECT r.queryId,
ARRAY_AGG(DISTINCT r.requiredQueryId)
FILTER (WHERE r.requiredQueryId != '00000000-0000-0000-0000-000000000000')::uuid[]
as requiredIds
FROM query AS q
LEFT JOIN requiredQueries AS r ON q.id = r.queryId
and $2 >= r.addedVersion
and $2 < COALESCE(r.removedVersion, $2 + 1)
WHERE q.id = $1
GROUP BY q.id, q.type, q.activeversion, q.latestversion, c.config;
and @version >= r.addedVersion
and (r.removedVersion is null or @version < r.removedVersion)
GROUP BY r.queryId
)
SELECT DISTINCT q.id, q.type, q.activeVersion, q.latestVersion, c.config,
coalesce(
r.requiredIds,
array[]::uuid[]
)::uuid[] as requiredIds
FROM query AS q
LEFT JOIN config AS c ON q.id = c.queryId
LEFT JOIN requiredIds AS r ON q.id = r.queryId;
-- name: ListQueries :many
SELECT * FROM fullActiveQueries;
@@ -57,4 +76,7 @@ WITH doc AS (
SELECT dt.queryId
FROM collectorQueryDependencyTree as dt
JOIN doc as d on d.jobId = dt.jobId
where $1 = any(dt.requiredIds);
where $1 = any(dt.requiredIds);
-- name: ListQueryJobIDs :many
SELECT jobId FROM collectorQueryDependencyTree WHERE queryId = $1;