Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add components to config details view #990

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions views/006_config_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,8 @@ CREATE OR REPLACE VIEW config_detail AS
'changes', COALESCE(config_changes.changes_count, 0),
'playbook_runs', COALESCE(playbook_runs.playbook_runs_count, 0),
'checks', COALESCE(config_checks.checks_count, 0)
) as summary
) as summary,
components
FROM config_items as ci
LEFT JOIN
(SELECT config_id, count(*) as related_count FROM config_relationships GROUP BY config_id) as related
Expand Down Expand Up @@ -765,7 +766,18 @@ CREATE OR REPLACE VIEW config_detail AS
(SELECT config_id, count(*) as checks_count from check_config_relationships
WHERE deleted_at IS NULL
GROUP BY config_id) as config_checks
ON ci.id = config_checks.config_id;
ON ci.id = config_checks.config_id
LEFT JOIN
(SELECT
config_id, json_agg(components) as components
FROM
(SELECT
ccr.config_id as config_id, components
FROM config_component_relationships as ccr
LEFT JOIN components ON components.id = ccr.component_id
) as config_components
GROUP BY config_id) as gcc
ON ci.id = gcc.config_id;

--- config_path is a function that given a config id returns its path by walking the tree recursively up using the parent id and then joining the ids with a `.`
CREATE OR REPLACE FUNCTION config_path(UUID)
Expand Down
Loading