修正北京时间并更换新闻候选源

This commit is contained in:
Codex
2026-07-08 23:08:55 +08:00
parent 3ece2327c8
commit 88e1cf4b7a
10 changed files with 178 additions and 55 deletions
+12 -5
View File
@@ -1,12 +1,12 @@
from __future__ import annotations
from datetime import datetime
from hashlib import sha256
from typing import Optional
from sqlalchemy import select
from sqlalchemy.orm import Session
from app.core.timezone import beijing_now
from app.db.models import AgentRun, Report, Signal, Topic
from app.schemas.agent import SignalItem
@@ -23,20 +23,20 @@ class AgentRepository:
def create_run(self, request_payload: dict) -> AgentRun:
# 运行先进入running状态,情报和日报保存完成后再标记完成。
run = AgentRun(status="running", request_payload=request_payload)
run = AgentRun(status="running", started_at=beijing_now(), request_payload=request_payload)
self.db.add(run)
self.db.flush()
return run
def mark_run_complete(self, run: AgentRun, raw_response: dict) -> None:
run.status = "completed"
run.finished_at = datetime.utcnow()
run.finished_at = beijing_now()
run.raw_response = raw_response
self.db.flush()
def mark_run_failed(self, run: AgentRun, error: str) -> None:
run.status = "failed"
run.finished_at = datetime.utcnow()
run.finished_at = beijing_now()
run.error = error
self.db.flush()
@@ -77,6 +77,7 @@ class AgentRepository:
published_at=item.published_at,
importance=item.importance,
entities=item.entities,
created_at=beijing_now(),
)
self.db.add(signal)
self.db.flush()
@@ -88,7 +89,13 @@ class AgentRepository:
def save_report(self, run: AgentRun, title: str, content_md: str, file_path: str) -> Report:
# 文件路径便于人工打开Markdown产物,MySQL保存可查询正文。
report = Report(run_id=run.id, title=title, content_md=content_md, file_path=file_path)
report = Report(
run_id=run.id,
title=title,
content_md=content_md,
file_path=file_path,
created_at=beijing_now(),
)
self.db.add(report)
self.db.flush()
return report