Route rescore matches to manual review
This commit is contained in:
@@ -19,6 +19,8 @@ if str(ROOT) not in sys.path:
|
||||
from services.competitor_match_attempt_rescore_audit import ( # noqa: E402
|
||||
DEFAULT_RESCAN_STATUSES,
|
||||
build_match_attempt_rescore_audit,
|
||||
fetch_match_attempt_rescore_rows,
|
||||
materialize_rescore_accept_reviews,
|
||||
summarize_match_attempt_rescore,
|
||||
)
|
||||
from services.competitor_price_feeder import MIN_MATCH_SCORE # noqa: E402
|
||||
@@ -59,10 +61,17 @@ def main(argv: list[str] | None = None) -> int:
|
||||
parser.add_argument("--limit", type=int, default=100)
|
||||
parser.add_argument("--sample-limit", type=int, default=20)
|
||||
parser.add_argument("--min-score", type=float, default=MIN_MATCH_SCORE)
|
||||
parser.add_argument(
|
||||
"--apply-accepted",
|
||||
action="store_true",
|
||||
help="Append accepted-current rows to competitor_match_attempts for manual review; never writes competitor_prices.",
|
||||
)
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
statuses = tuple(args.statuses or DEFAULT_RESCAN_STATUSES)
|
||||
if args.input:
|
||||
if args.apply_accepted:
|
||||
parser.error("--apply-accepted requires DB mode; do not combine it with --input.")
|
||||
rows = [row for row in _read_jsonl(args.input) if not row.get("_invalid_json")]
|
||||
summary = summarize_match_attempt_rescore(
|
||||
rows,
|
||||
@@ -73,15 +82,36 @@ def main(argv: list[str] | None = None) -> int:
|
||||
from config import DATABASE_PATH
|
||||
|
||||
engine = create_engine(DATABASE_PATH)
|
||||
summary = build_match_attempt_rescore_audit(
|
||||
engine,
|
||||
source=args.source,
|
||||
statuses=statuses,
|
||||
reason_filter=args.reason_filter or None,
|
||||
limit=args.limit,
|
||||
min_score=args.min_score,
|
||||
sample_limit=args.sample_limit,
|
||||
)
|
||||
if args.apply_accepted:
|
||||
with engine.begin() as conn:
|
||||
rows = fetch_match_attempt_rescore_rows(
|
||||
conn,
|
||||
source=args.source,
|
||||
statuses=statuses,
|
||||
reason_filter=args.reason_filter or None,
|
||||
limit=args.limit,
|
||||
)
|
||||
summary = summarize_match_attempt_rescore(
|
||||
rows,
|
||||
min_score=args.min_score,
|
||||
sample_limit=args.sample_limit,
|
||||
)
|
||||
summary["materialize"] = materialize_rescore_accept_reviews(
|
||||
conn,
|
||||
rows,
|
||||
source=args.source,
|
||||
min_score=args.min_score,
|
||||
)
|
||||
else:
|
||||
summary = build_match_attempt_rescore_audit(
|
||||
engine,
|
||||
source=args.source,
|
||||
statuses=statuses,
|
||||
reason_filter=args.reason_filter or None,
|
||||
limit=args.limit,
|
||||
min_score=args.min_score,
|
||||
sample_limit=args.sample_limit,
|
||||
)
|
||||
|
||||
print(json.dumps(summary, ensure_ascii=False, indent=2, default=str))
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user