数据看板分享模式:新增 series 接口、免登录路径、时间范围查询

- 新增 /api/v1/data-dashboard/ocr/series 路由(按采集轮次序列)
- ocr_dashboard_service 新增 get_series 透传
- /api/v1/data-dashboard/ 加入免登录 open_paths
- summary/comparison 路由透传 start_date/end_date
- evidences 放宽必填校验(支持时间范围替代批次)
This commit is contained in:
2026-08-28 17:21:56 +08:00
parent e188c50fab
commit af340206a5
2 changed files with 32 additions and 7 deletions

View File

@@ -46,21 +46,32 @@ def list_collections(batch_key: str) -> list[dict[str, Any]]:
return _get(f"/xhs/ocr/batches/{batch_key.strip()}/collections") or []
def get_summary(batch_key: str = "", collection_key: str = "") -> dict[str, Any]:
def get_summary(batch_key: str = "", collection_key: str = "",
start_date: str = "", end_date: str = "") -> dict[str, Any]:
return _get("/xhs/ocr/dashboard/summary", {
"batch_key": batch_key, "collection_key": collection_key,
"start_date": start_date, "end_date": end_date,
}) or {}
def get_comparison(batch_key: str = "", collection_key: str = "") -> dict[str, Any]:
def get_series(batch_key: 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,
}) or {"items": [], "subjects": []}
def get_comparison(batch_key: str = "", collection_key: str = "",
start_date: str = "", end_date: str = "") -> dict[str, Any]:
return _get("/xhs/ocr/dashboard/comparison", {
"batch_key": batch_key, "collection_key": collection_key,
"start_date": start_date, "end_date": end_date,
}) or {}
def list_results(params: dict[str, Any]) -> dict[str, Any]:
allowed = {
"batch_key", "collection_key", "question_code", "search_keyword", "city",
"batch_key", "collection_key", "start_date", "end_date",
"question_code", "search_keyword", "city",
"department_name", "minsheng_matched", "cobranded_matched", "is_valid",
"page", "page_size",
}
@@ -82,10 +93,11 @@ def get_result_matches(result_id: int) -> dict[str, Any]:
def list_evidences(params: dict[str, Any]) -> dict[str, Any]:
allowed = {"batch_key", "collection_key", "question_code", "evidence_type", "limit"}
allowed = {"batch_key", "collection_key", "start_date", "end_date", "question_code", "evidence_type", "limit"}
query = {key: value for key, value in params.items() if key in allowed}
if not str(query.get("batch_key") or "").strip() or not str(query.get("collection_key") or "").strip():
raise TaskError("OCR_EVIDENCE_SCOPE_REQUIRED", "batch_key 和 collection_key 不能为空", 422)
if not (str(query.get("batch_key") or "").strip() or str(query.get("collection_key") or "").strip()
or str(query.get("start_date") or "").strip() or str(query.get("end_date") or "").strip()):
raise TaskError("OCR_EVIDENCE_SCOPE_REQUIRED", "batch_key/collection_key 或 start_date/end_date 至少传入一种", 422)
limit = int(query.get("limit") or 10)
if not 1 <= limit <= 100:
raise TaskError("OCR_EVIDENCE_LIMIT_INVALID", "limit 必须在 1 到 100 之间", 422)