Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions app/services/roadmap_assess.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from app.services.roadmap import rule_filter, llm_analyzer, market_tier, market_loader
from app.services.roadmap_merger import run_merged
from app.services._rag_utils import _fetch_code_analysis as _fetch_project
from app.services.webhook import notify_be
from app.services.webhook import notify_be_roadmap
from app.jobs.store import JobStatus, update_job

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -197,7 +197,15 @@ def _run() -> list[dict[str, Any]]:
logger.error("[로드맵] 평가 태스크 실패: %s", e)
update_job(job_id, JobStatus.ERROR, message=error_message)
finally:
# 로드맵은 PDF가 없으므로 공용 /jobs/complete가 아니라 result를 싣는
# /roadmap/complete로 콜백한다(BE가 result_json 저장 후 FE로 전달).
status = "ERROR" if error_message else "DONE"
try:
await notify_be(ai_job_id=ai_job_id, output_pdf_url=None, error_message=error_message)
await notify_be_roadmap(
ai_job_id=ai_job_id,
status=status,
result=results,
error_message=error_message,
)
except Exception as webhook_err:
logger.warning("[Webhook] 콜백 실패 (결과는 저장됨): %s", webhook_err)
logger.warning("[Webhook] 로드맵 콜백 실패 (결과는 저장됨): %s", webhook_err)
24 changes: 24 additions & 0 deletions app/services/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,27 @@ async def notify_be(
resp = await client.post(be_url, json=payload, headers=headers)
resp.raise_for_status()
logger.info("[Webhook] 전송 완료: %s", ai_job_id)


async def notify_be_roadmap(
ai_job_id: str,
status: str,
result: list | dict | None = None,
error_message: str | None = None,
) -> None:
"""로드맵 전용 완료 콜백. PDF가 없는 로드맵은 평가 결과(result)를 BE에 직접 실어 보낸다.
(포폴용 notify_be는 result를 싣지 않으므로 별도 엔드포인트로 분리.)"""
settings = get_settings()
payload = {
"ai_job_id": ai_job_id,
"status": status,
"result": result,
"error_message": error_message,
}
be_url = f"{settings.be_base_url}/api/v1/ai/roadmap/complete"
headers = {"X-INTERNAL-API-KEY": settings.passfolio_internal_api_key}
logger.info("[Webhook] POST %s | status=%s | job=%s", be_url, status, ai_job_id)
async with httpx.AsyncClient(timeout=10.0) as client:
resp = await client.post(be_url, json=payload, headers=headers)
resp.raise_for_status()
logger.info("[Webhook] 로드맵 전송 완료: %s", ai_job_id)
Loading