feat: RapidOCR default OCR engine, office-only ocr_engine, drop operator toggle
ci / smoke (push) Canceled after 0s

This commit is contained in:
andrew committed 2026-09-25 16:18:41 +07:00
1 parent 080237ad3b
commit fbba169507
16 files changed
+137 -112

No files matched your search

+20 -19
View File
@@ -75,6 +75,7 @@ from src.do_batch import (
is_valid_ocr_engine,
net_counts,
normalize_batch_mode,
OCR_ENGINES,
retention_cutoff_date,
should_discard_batch,
should_purge_counting_date,
@@ -300,7 +301,7 @@ def _write_do_settings(data: dict) -> None:
payload = {
"require_plate": bool(data.get("require_plate", False)),
"require_do": bool(data.get("require_do", True)),
"ocr_engine": str(data.get("ocr_engine", "tesseract")).lower(),
"ocr_engine": str(data.get("ocr_engine", "rapid")).lower(),
"updated_at": datetime.now().isoformat(),
}
tmp = DO_SETTINGS_PATH + ".tmp"
@@ -831,32 +832,32 @@ def api_do_settings():
current = _read_do_settings()
office = is_office_request()
wrote = False
# ocr_engine: both ports allowed
# require_plate / require_do / ocr_engine: office only
gated_keys = ("require_plate", "require_do", "ocr_engine")
if any(k in req_data for k in gated_keys):
if not office:
return jsonify({
"success": False,
"error": "require_plate/require_do/ocr_engine hanya dari port kantor",
}), 403
if "ocr_engine" in req_data:
eng = str(req_data.get("ocr_engine", "")).lower()
if not is_valid_ocr_engine(eng):
return jsonify({
"success": False,
"error": f"Invalid ocr_engine. Use one of {list(('tesseract','paddle','none'))}",
"error": f"Invalid ocr_engine. Use one of {list(OCR_ENGINES)}",
}), 400
current["ocr_engine"] = eng
wrote = True
# require_plate / require_do: office only
plate_keys = ("require_plate", "require_do")
if any(k in req_data for k in plate_keys):
if not office:
return jsonify({
"success": False,
"error": "require_plate/require_do hanya dari port kantor",
}), 403
if "require_plate" in req_data:
current["require_plate"] = bool(
str(req_data.get("require_plate")).lower() in
("1", "true", "yes", "on"))
if "require_do" in req_data:
current["require_do"] = bool(
str(req_data.get("require_do")).lower() in
("1", "true", "yes", "on"))
if "require_plate" in req_data:
current["require_plate"] = bool(
str(req_data.get("require_plate")).lower() in
("1", "true", "yes", "on"))
if "require_do" in req_data:
current["require_do"] = bool(
str(req_data.get("require_do")).lower() in
("1", "true", "yes", "on"))
if any(k in req_data for k in ("require_plate", "require_do")):
wrote = True
if not wrote:
return jsonify({"success": False, "error": "No known settings fields"}), 400