pbl_evidence/wwwroot/api/pbl_evidence_aggregate.dspy
2026-09-22 14:13:03 +08:00

21 lines
1.1 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# pbl_evidence/api/pbl_evidence_aggregate.dspy
# M5b 契约②:证据聚合(四类计数 + 覆盖度 + 分组 + 时间水位)。
# Q-OPEN-10:预览 / Playtest 数据默认剔除,需显式 include_preview=true 才纳入。
# dspy 铁律:无 import、无 ServerEnv()、显式 return。
debug(f'pbl_evidence/api/pbl_evidence_aggregate.dspy: START params_kw={dict(params_kw)}')
try:
kw = dict(params_kw)
for flag in ('include_preview', 'include_student_private'):
if isinstance(kw.get(flag), str):
kw[flag] = kw[flag].strip().lower() in ('1', 'true', 'yes', 'y')
res = await pbl_evidence_aggregate(**kw)
status = 'OK' if res.get('ok') else 'ERROR'
debug(f'pbl_evidence_aggregate.dspy: DONE total={res.get("total")} '
f'groups={len(res.get("groups") or [])}')
return {'status': status, 'data': res, 'message': res.get('message') or '',
'total': res.get('total')}
except Exception as e:
error(f'pbl_evidence_aggregate.dspy: FAIL {format_exc()}')
return {'status': 'ERROR', 'data': None, 'message': str(e)}