Skip to content

Commit

Permalink
fix: return single row for config detail
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra authored and moshloop committed Nov 1, 2024
1 parent f66a0a5 commit 2d8bfcb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions views/006_config_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ CREATE OR REPLACE VIEW config_detail AS
json_build_object(
'relationships', COALESCE(related.related_count, 0) + COALESCE(reverse_related.related_count, 0),
'analysis', COALESCE(analysis.analysis_count, 0),
'changes', COALESCE(change_summary.changes_count, 0),
'changes', COALESCE(change_summary.total_changes_count, 0),
'playbook_runs', COALESCE(playbook_runs.playbook_runs_count, 0),
'checks', COALESCE(config_checks.checks_count, 0)
) as summary,
Expand All @@ -856,9 +856,11 @@ CREATE OR REPLACE VIEW config_detail AS
GROUP BY config_id) as analysis
ON ci.id = analysis.config_id
LEFT JOIN
(SELECT config_item_summary_7d.config_id, config_item_summary_7d.config_changes_count AS changes_count
FROM config_item_summary_7d) AS change_summary
ON ci.path LIKE '%' || change_summary.config_id || '%'
(SELECT ci.id AS config_id, SUM(cs.config_changes_count) AS total_changes_count
FROM config_items ci
LEFT JOIN config_item_summary_7d cs ON ci.path LIKE '%' || cs.config_id || '%'
GROUP BY ci.id) AS change_summary
ON ci.id = change_summary.config_id
LEFT JOIN
(SELECT config_id, count(*) as playbook_runs_count FROM playbook_runs
WHERE start_time > NOW() - interval '30 days'
Expand Down

0 comments on commit 2d8bfcb

Please sign in to comment.