Keep top human/machine legacy categories below 0.5 for privacy blocking
The portal blocks images whose top ICU category is human or machine for non-admins. With the 0.5 threshold, 103 such images would have lost their detection and become visible. Those categories are now migrated when they were the image's top category, regardless of score. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+11
-4
@@ -77,6 +77,14 @@ def migrate(conn: psycopg.Connection, batch_size: int) -> None:
|
||||
print("Neu angelegt: " + ", ".join(f"{k}={v}" for k, v in totals.items()), flush=True)
|
||||
|
||||
|
||||
# Welche Zeilen aus remote_cam.category (Alias c) zu detection werden -- wie in 002.
|
||||
DETECTION_FILTER = (
|
||||
"c.category IS NOT NULL AND c.category NOT IN ('', 'none') AND (c.score >= 0.5 "
|
||||
"OR (c.category IN ('human', 'machine') AND NOT EXISTS (SELECT 1 FROM remote_cam.category c2 "
|
||||
"WHERE c2.image_uuid = c.image_uuid "
|
||||
"AND (c2.score > c.score OR (c2.score = c.score AND c2.category < c.category)))))"
|
||||
)
|
||||
|
||||
# Lesende Vorschau; die Bedingungen spiegeln 002 (detection-Filter) und 003 (Zwillinge).
|
||||
PLAN_QUERIES = [
|
||||
("image(entrance) neu",
|
||||
@@ -88,8 +96,7 @@ PLAN_QUERIES = [
|
||||
"AND s.source_ref = m.metadata_uuid)"),
|
||||
("detection(entrance) neu",
|
||||
"SELECT count(*) FROM remote_cam.category c JOIN remote_cam.metadata m ON m.metadata_uuid = c.image_uuid "
|
||||
"WHERE m.imei IS NOT NULL AND m.servertime IS NOT NULL "
|
||||
"AND c.category IS NOT NULL AND c.category NOT IN ('', 'none') AND c.score >= 0.5 "
|
||||
"WHERE m.imei IS NOT NULL AND m.servertime IS NOT NULL AND " + DETECTION_FILTER + " "
|
||||
"AND NOT EXISTS (SELECT 1 FROM remote_cam.detection d WHERE d.image_uuid = m.metadata_uuid::uuid "
|
||||
"AND d.source = 'entrance')"),
|
||||
("Gundi-Zwillinge (nach Migration zu entfernen)",
|
||||
@@ -160,10 +167,10 @@ def verify(conn: psycopg.Connection) -> bool:
|
||||
("metadata == camera_status(entrance)",
|
||||
"SELECT (SELECT count(*) FROM remote_cam.metadata), "
|
||||
"(SELECT count(*) FROM remote_cam.camera_status WHERE source = 'entrance')"),
|
||||
("category (Score >= 0.5, ohne ''/none) == detection(entrance)",
|
||||
("category (Score >= 0.5 bzw. Top human/machine, ohne ''/none) == detection(entrance)",
|
||||
"SELECT (SELECT count(*) FROM remote_cam.category c JOIN remote_cam.metadata m "
|
||||
"ON m.metadata_uuid = c.image_uuid WHERE m.imei IS NOT NULL AND m.servertime IS NOT NULL "
|
||||
"AND c.category NOT IN ('', 'none') AND c.score >= 0.5), "
|
||||
"AND " + DETECTION_FILTER + "), "
|
||||
"(SELECT count(*) FROM remote_cam.detection WHERE source = 'entrance')"),
|
||||
("keine Gundi-Bilder mit Legacy-Zwilling",
|
||||
"SELECT 0, count(*) FROM remote_cam.image g JOIN remote_cam.image e "
|
||||
|
||||
Reference in New Issue
Block a user