fix(targets): the targets list counts findings live #358

Merged
sharang merged 1 commits from fix/target-findings-count into main 2026-09-23 20:39:19 +00:00
Owner

The targets list showed 0 findings for a target whose findings were all entered by hand or imported. The stored findings_count only changes when a scan runs, so manual findings, imports and deletions left it wrong.

What changes

  • GET /api/v1/targets now counts each target's findings in one aggregation, alongside the query for the last scan run, and returns that live number as findings_count. The query uses the existing repo_id index on findings.
  • If the count query fails, the list falls back to the stored counts rather than showing zeros.

Checked

  • The manual-findings integration test now also asserts that the targets list shows 3 findings for a target that has never been scanned.
  • fmt; clippy with the CI flags (-p compliance-agent, lib and tests); agent lib tests.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p

The targets list showed 0 findings for a target whose findings were all entered by hand or imported. The stored `findings_count` only changes when a scan runs, so manual findings, imports and deletions left it wrong. ## What changes - `GET /api/v1/targets` now counts each target's findings in one aggregation, alongside the query for the last scan run, and returns that live number as `findings_count`. The query uses the existing `repo_id` index on findings. - If the count query fails, the list falls back to the stored counts rather than showing zeros. ## Checked - The manual-findings integration test now also asserts that the targets list shows 3 findings for a target that has never been scanned. - fmt; clippy with the CI flags (`-p compliance-agent`, lib and tests); agent lib tests. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang added 1 commit 2026-09-23 20:09:15 +00:00
fix(targets): the targets list counts findings live
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 7m3s
561d090846
The stored findings_count only moves when a scan runs, so findings
entered by hand, imported or deleted left the list wrong (0 for a
target with only manual findings). The list now counts each target's
findings in one aggregation and falls back to the stored count if the
query fails.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang merged commit 0441220330 into main 2026-09-23 20:39:19 +00:00
Sign in to join this conversation.