(user_id: str)
| 3070 | for index, doc in enumerate(docs or []) |
| 3071 | ] |
| 3072 | |
| 3073 | |
| 3074 | def _reports_payload(docs: Iterable[Dict[str, Any]], *, write_feishu_requested: bool) -> Dict[str, Any]: |
| 3075 | created_docs = _doc_payloads(docs) |
| 3076 | feishu_errors = [ |
| 3077 | str(doc.get("feishu_error") or "").strip() |
| 3078 | for doc in created_docs |
| 3079 | if str(doc.get("feishu_error") or "").strip() |
| 3080 | ] |
| 3081 | feishu_warning = None |
| 3082 | if write_feishu_requested and feishu_errors: |
| 3083 | feishu_warning = ( |
| 3084 | "飞书文档发送失败,已保留本地 Markdown。" |
| 3085 | "请检查 FEISHU_CLI_CMD / lark-cli 登录状态,以及 FEISHU_APP_ID、FEISHU_APP_SECRET 等飞书环境变量。" |
| 3086 | f"错误:{feishu_errors[0]}" |
| 3087 | ) |
| 3088 | elif write_feishu_requested and created_docs and not any(doc.get("url") for doc in created_docs): |
| 3089 | feishu_warning = ( |
| 3090 | "未拿到飞书文档链接,已保留本地 Markdown。" |
| 3091 | "请检查飞书环境变量和 lark-cli 登录状态。" |
| 3092 | ) |
| 3093 | return { |
| 3094 | "created_docs": created_docs, |
| 3095 | "count": len(created_docs), |
| 3096 | "write_feishu_requested": write_feishu_requested, |
| 3097 | "feishu_warning": feishu_warning, |
| 3098 | } |
| 3099 | |
| 3100 | |
| 3101 | def _report_summary_payload(report: Dict[str, Any]) -> Dict[str, Any]: |
| 3102 | return { |
| 3103 | "report_id": report["report_id"], |
| 3104 | "title": report["title"], |
| 3105 | "user_id": report["user_id"], |
| 3106 | "paper_id": report["paper_id"], |
| 3107 | "arxiv_id": report["arxiv_id"], |
| 3108 | "saved_at": report["saved_at"], |
| 3109 | "updated_at": report["updated_at"], |
| 3110 | "report_path": report["report_path"], |
| 3111 | "doc_url": report["doc_url"], |
| 3112 | "doc_token": report["doc_token"], |
| 3113 | "pdf_url": report["pdf_url"], |
| 3114 | "abs_url": report["abs_url"], |
| 3115 | "report_version": report["report_version"], |
| 3116 | "generation_provider": report["generation_provider"], |
| 3117 | "generation_model": report["generation_model"], |
| 3118 | "snippet": report["snippet"], |
| 3119 | } |
| 3120 | |
| 3121 | |
| 3122 | def list_reports( |
| 3123 | user_id: str = "", |
| 3124 | query: str = "", |
| 3125 | days: int = 30, |
| 3126 | limit: int = 80, |
| 3127 | exact_date: str = "", |
| 3128 | ) -> Dict[str, Any]: |
| 3129 | normalized_user = str(user_id or "").strip() |
no test coverage detected