Files
query-orchestration/database/migrations/20250120165410_create_fullactivecollector_view.up.sql
T
Michael McGuinness 4ccb980593 Merged in feature/jobcollector (pull request #30)
Initial Job Collector (changes pending)

* movearroundtocleancollector

* internalgetfunctions

* completecollectorquery

* simplify

* fixtests

* addvendor

* noplaceholder
2025-01-21 12:28:46 +00:00

9 lines
504 B
SQL

CREATE VIEW fullActiveCollectors AS
SELECT DISTINCT c.id, c.jobId, c.minCleanVersion, c.minTextVersion, c.activeVersion, c.latestVersion,
jsonb_object_agg(q.name, q.queryId) FILTER (WHERE q.name is not null) AS fields
FROM collectors AS c
LEFT JOIN collectorQueries AS q ON c.id = q.collectorId
AND c.activeVersion >= q.addedVersion
and c.activeVersion < COALESCE(q.removedVersion, c.activeVersion + 1)
GROUP BY c.id, c.jobId, c.minCleanVersion, c.minTextVersion;