-
Notifications
You must be signed in to change notification settings - Fork 14
Add processed/unprocessed filter to captures list view #1326
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
Merged
Merged
Changes from 11 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
7b14b8d
docs: design spec for captures processed/not-processed filter
mihow 9a41c7d
docs: implementation plan for captures processed filter
mihow d18392f
test: cover has_detections filter on captures list endpoint
mihow 98e259b
feat(ui): add Processed / Not processed label strings
mihow 741daa8
feat(ui): add ProcessingStatusFilter select component
mihow 0d85574
feat(ui): register processing-status filter (has_detections)
mihow 8e71fd5
feat(ui): show processing-status filter on captures list
mihow dcb98cc
Merge remote-tracking branch 'origin/main' into worktree-capture-filters
mihow 658d58c
feat: split processed status from real-detections; add Last processed…
mihow ca47bb0
refactor(ui): clearer prop naming in ProcessingStatusFilter
mihow 097e5d2
refactor(captures): reuse with_was_processed() for the processed filter
mihow dae73c5
feat(captures): move Last processed column to the captures list
mihow a3fab55
perf: count processed/has_detections captures by subtraction
mihow 7c4d1da
revert: drop processed/has_detections count-by-subtraction paginator
mihow b42bfcd
Merge branch 'main' into worktree-capture-filters
annavik bb01ef7
Merge origin/main into worktree-capture-filters
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
docs/claude/planning/2026-05-28-captures-processed-filter-design.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| # Captures list — "Processed / Not processed" filter | ||
|
|
||
| Date: 2026-05-28 | ||
| Status: design approved, pending spec review | ||
| Scope: first of several planned captures-list filters; this PR ships the processed filter only. | ||
|
|
||
| ## Goal | ||
|
|
||
| Add a "Processing status" filter to the Captures (SourceImage) list view, letting users | ||
| narrow to captures that have been processed, not processed, or all (no filter). Lay the | ||
| groundwork (a planned filter set) for additional filters in later PRs. | ||
|
|
||
| "Processed" = the image has been run through detection. Because PR #1093 writes a null | ||
| Detection marker for the "processed, found nothing" case, the presence of *any* Detection | ||
| row is an accurate signal of "was processed." | ||
|
|
||
| ## Backend — no change required | ||
|
|
||
| The filter already exists and is exercised by the list endpoint: | ||
|
|
||
| - `ami/main/api/views.py:630-636` — `SourceImageViewSet.filter_by_has_detections` | ||
| handles `?has_detections=true|false` by annotating | ||
| `Exists(Detection.objects.filter(source_image=OuterRef("pk")))` and filtering on it. | ||
| (`SourceImageViewSet` at `views.py:528`.) | ||
| - Called from `get_queryset` only for the `list` action (`views.py:600`), which is what | ||
| the captures list uses. | ||
|
|
||
| Decision: reuse the existing `has_detections` query param. Zero backend change, already | ||
| tested behavior. The param name (`has_detections`) means "was processed" because of the | ||
| null-marker convention; we surface it to users with the label "Processing status" and keep | ||
| `has_detections` as the internal query key. This name/meaning gap is the one known wart and | ||
| is documented here rather than fixed (a `was_processed` alias was considered and rejected to | ||
| avoid extra surface area). | ||
|
|
||
| ## Frontend — four wiring changes | ||
|
|
||
| 1. **New component** `ui/src/components/filtering/filters/processing-status-filter.tsx`. | ||
| Model on `verification-status-filter.tsx`. Two options: "Processed" (true) / | ||
| "Not processed" (false). Wire `onValueChange={onAdd}` directly so both true and false | ||
| are settable. (The generic `BooleanFilter` is unusable here: its "No" branch calls | ||
| `onClear()` instead of filtering to false — see `boolean-filter.tsx:21-27`.) | ||
| Use a translated label string for the two options (add to `utils/language` if needed). | ||
|
|
||
| 2. **Register the component** in `ui/src/components/filtering/filter-control.tsx` | ||
| `ComponentMap`: `has_detections: ProcessingStatusFilter`. | ||
|
|
||
| 3. **Register the filter** in `ui/src/utils/useFilters.ts` `AVAILABLE_FILTERS`: | ||
| `{ label: 'Processing status', field: 'has_detections', tooltip: { text: ... } }`. | ||
|
|
||
| 4. **Render it** on the captures page `ui/src/pages/captures/captures.tsx` (inside the | ||
| existing `FilterSection`, alongside `deployment` and `collections`): | ||
| `<FilterControl field="has_detections" />`. | ||
|
|
||
| State, URL params, page reset, and the clear-X ("All") behavior all come from the existing | ||
| `useFilters` machinery — no changes there. | ||
|
|
||
| ## Data flow | ||
|
|
||
| UI select -> `addFilter('has_detections', 'true'|'false')` -> URL search param -> | ||
| `useFilters` -> `useCaptures` builds `?has_detections=...` via `getFetchUrl` | ||
| (`ui/src/data-services/utils.ts`) -> DRF `filter_by_has_detections` -> filtered queryset. | ||
| Clear-X removes the param -> "All". | ||
|
|
||
| ## Testing | ||
|
|
||
| - Backend: verify existing coverage for `?has_detections=true|false` on the captures list | ||
| endpoint; add a test if missing (both branches + absent param). | ||
| - Frontend: manual verification against the running stack — select Processed, Not processed, | ||
| and clear; confirm result counts change and the URL param round-trips. | ||
|
|
||
| ## Out of scope (planned follow-up PRs) | ||
|
|
||
| To live in a collapsible "Advanced" `FilterSection` on the captures page later: | ||
|
|
||
| - **Date range** — `date_start`/`date_end` already in the FE registry with a `DateFilter` | ||
| component, but the SourceImage viewset needs backend support mapping them to a `timestamp` | ||
| range (new work). | ||
| - **Station** — already available via the existing `deployment` filter. | ||
| - **Site** — add `deployment__research_site` to `filterset_fields` + a Site filter component. | ||
| - **Device** — add `deployment__device` to `filterset_fields` + a Device filter component. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use pixel-space bbox fixtures in these new detection rows.
These new tests use normalized-looking bbox values, but this repo’s detection bbox convention is pixel coordinates. Please switch to integer pixel boxes to match canonical behavior and avoid brittle assumptions in future validation paths.
💡 Proposed test fixture update
Based on learnings:
Detection.bbox/BoundingBoxvalues in this repo use absolute pixel coordinate space (not normalized [0–1] floats).Also applies to: 1460-1460
🤖 Prompt for AI Agents