feat(ocr-dashboard): 透传按主体名跨批次采集记录接口

- ocr_dashboard_service.py 新增 list_collections_by_subject() 函数
- get_series() 增加 subject_name 参数
- app.py 新增路由 /api/v1/data-dashboard/ocr/batches/subject/<subject_name>/collections
- 透传代理至 xiaoti-framework crawler 服务
This commit is contained in:
2026-09-02 18:27:00 +08:00
parent fe15b11733
commit 26e91597ab
2 changed files with 22 additions and 2 deletions

10
app.py
View File

@@ -23,6 +23,7 @@ from ocr_dashboard_service import (
get_summary as get_ocr_dashboard_summary,
list_batches as list_ocr_batches,
list_collections as list_ocr_collections,
list_collections_by_subject as list_ocr_collections_by_subject,
list_evidences as list_ocr_evidences,
list_configured_notes as list_ocr_configured_notes,
export_evidences as export_ocr_evidences,
@@ -393,6 +394,14 @@ def create_app() -> Flask:
def query_ocr_dashboard_collections(batch_key: str):
return jsonify({"data": list_ocr_collections(batch_key), "request_id": g.request_id})
@app.route("/api/v1/data-dashboard/ocr/batches/subject/<subject_name>/collections", methods=["GET"])
def query_ocr_collections_by_subject(subject_name: str):
return jsonify({"data": list_ocr_collections_by_subject(
subject_name,
request.args.get("start_date", "").strip(),
request.args.get("end_date", "").strip(),
), "request_id": g.request_id})
@app.route("/api/v1/data-dashboard/ocr/summary", methods=["GET"])
def query_ocr_dashboard_summary():
return jsonify({"data": get_ocr_dashboard_summary(
@@ -406,6 +415,7 @@ def create_app() -> Flask:
def query_ocr_dashboard_series():
return jsonify({"data": get_ocr_dashboard_series(
request.args.get("batch_key", "").strip(),
request.args.get("subject_name", "").strip(),
request.args.get("start_date", "").strip(),
request.args.get("end_date", "").strip(),
), "request_id": g.request_id})

View File

@@ -49,6 +49,16 @@ def list_collections(batch_key: str) -> list[dict[str, Any]]:
return _get(f"/xhs/ocr/batches/{batch_key.strip()}/collections") or []
def list_collections_by_subject(subject_name: str, start_date: str = "", end_date: str = "") -> list[dict[str, Any]]:
"""按主体名查询该主体下所有批次的采集任务。用于同名主体多批次合并展示。"""
if not subject_name.strip():
raise TaskError("OCR_SUBJECT_REQUIRED", "subject_name 不能为空", 422)
return _get(
f"/xhs/ocr/batches/subject/{subject_name.strip()}/collections",
{"start_date": start_date, "end_date": end_date},
) or []
def get_summary(batch_key: str = "", collection_key: str = "",
start_date: str = "", end_date: str = "") -> dict[str, Any]:
data = _get("/xhs/ocr/dashboard/summary", {
@@ -125,9 +135,9 @@ def _overlay_acceptance_questions(data: dict[str, Any], batch_key: str) -> dict[
return data
def get_series(batch_key: str = "", start_date: str = "", end_date: str = "") -> dict[str, Any]:
def get_series(batch_key: str = "", subject_name: str = "", start_date: str = "", end_date: str = "") -> dict[str, Any]:
return _get("/xhs/ocr/dashboard/series", {
"batch_key": batch_key, "start_date": start_date, "end_date": end_date,
"batch_key": batch_key, "subject_name": subject_name, "start_date": start_date, "end_date": end_date,
}) or {"items": [], "subjects": []}