Tweak Javascript to approve detections#71
Conversation
Tweak scrolling and approve functionality Also update detections and syncing Always keep detections in sync.
| det.confidence = 1.0; | ||
| var lbl = div.querySelector('.detection-label'); | ||
| if (lbl) lbl.textContent = det.label + ' 1.0'; | ||
| var sidebarItems = document.querySelectorAll('[data-unmatched-page="' + det.page_index + '"][data-unmatched-label="' + det.label + '"]'); |
There was a problem hiding this comment.
Greying by page+label affects all matching sidebar items, not just the approved one. If a page has two detections with the same label, both get greyed. Match by data-detection-id instead.
| } | ||
| ) | ||
|
|
||
| rects = [e for e in rects if e["rects"]] |
There was a problem hiding this comment.
New page entries are appended at the end, so redaction_rects can end up out of page_index order after a delete-then-add. Maybe add a final sort to keep diffs clean.
| y0__lte=det["bbox"][1] + 15, | ||
| ) | ||
| .order_by("pk") | ||
| .first() |
There was a problem hiding this comment.
The old code updated all matching rows in the bbox window. The new code boosts only the first one (.order_by("pk").first()). The old behavior looks like it was guarding against duplicate active detections in the same area (e.g. two pipeline runs both leaving an active row). Is that scenario possible here? If yes, we shoul .update(confidence=1.0) on the queryset instead of .first() so we dont leave a stale low confidence twin behind. If duplicates can't happen, the new code is fine as-is, just worth confirming.
Add small ui tweak to scanning portal
Also sync detections to disk every time.