diff --git a/scene_search/cli.py b/scene_search/cli.py index 4fdf597..e715d0a 100644 --- a/scene_search/cli.py +++ b/scene_search/cli.py @@ -393,7 +393,10 @@ def _route_rows( if override is not None: decisions[str(row["id"])] = override - routed: list[tuple] = list(reusable) + routed_by_id = { + str(row["id"]): (row, route, score, reason) + for row, route, score, reason in reusable + } with connect(settings.db_path) as con: for row in valid_rows: frame_id = str(row["id"]) @@ -408,13 +411,19 @@ def _route_rows( """, (route, reason, score, route_model, policy, frame_id), ) - routed.append((row, route, score, reason)) + routed_by_id[frame_id] = (row, route, score, reason) if verbose: print( f"{row['title']} @ {format_ts(int(row['timestamp_ms']))}: " f"score={score:.4f} -> {route} ({reason})" ) + routed = [ + routed_by_id[str(row["id"])] + for row in rows + if str(row["id"]) in routed_by_id + ] + if progress is not None: progress( {