add false-positive filter and bulk-clear for findings
Active Feedback Rules gets a status filter, and Field Baseline Deviations gets multi-select with a bulk apply bar. Bulk scope is restricted to exact-value/field only, so a batch action can never create a broad rule that would suppress a genuinely new deviation.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -105,6 +105,28 @@ class FeedbackStore:
|
||||
self.path.write_text(json.dumps(entries, indent=2), encoding="utf-8")
|
||||
return entry
|
||||
|
||||
def add_many(self, items: list[dict[str, object]]) -> dict[str, object]:
|
||||
"""Normalize and save a batch of entries with a single read-modify-write.
|
||||
|
||||
One bad item never blocks the rest — each is validated independently and
|
||||
failures are reported by index instead of aborting the whole batch.
|
||||
"""
|
||||
added_by_id: dict[str, dict[str, object]] = {}
|
||||
errors: list[dict[str, object]] = []
|
||||
for index, item in enumerate(items):
|
||||
try:
|
||||
entry = _normalize(item)
|
||||
added_by_id[entry["id"]] = entry # later duplicates in the same batch win, like sequential add() calls would
|
||||
except ValueError as exc:
|
||||
errors.append({"index": index, "error": str(exc)})
|
||||
added = list(added_by_id.values())
|
||||
entries = self.entries()
|
||||
entries = [value for value in entries if value.get("id") not in added_by_id]
|
||||
entries.extend(added)
|
||||
self.path.parent.mkdir(parents=True, exist_ok=True)
|
||||
self.path.write_text(json.dumps(entries, indent=2), encoding="utf-8")
|
||||
return {"added": added, "errors": errors, "remaining": len(entries)}
|
||||
|
||||
def revoke(self, entry_id: str) -> dict[str, object]:
|
||||
entries = self.entries()
|
||||
before = len(entries)
|
||||
|
||||
Reference in New Issue
Block a user