Skip to content

Commit

Permalink
chore: add components to config details view
Browse files Browse the repository at this point in the history
  • Loading branch information
mainawycliffe committed Aug 23, 2024
1 parent 8537cfd commit e09d53c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 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,
to_json(config_components.components) as 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,13 @@ 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 ccr.config_id as config_id, components FROM config_component_relationships as ccr
LEFT JOIN components ON components.id = ccr.component_id
WHERE ccr.component_id = components.id
) as config_components
ON ci.id = config_components.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

0 comments on commit e09d53c

Please sign in to comment.