from __future__ import annotations

from fastapi import APIRouter

from app.features.user_profile_scoring.scoring import build_user_profile_from_questionnaire
from app.features.user_profile_scoring.types import BuildUserProfileRequest, UserProfileV1_2_Extended

router = APIRouter(prefix="/v1/user-profile", tags=["user-profile"])


@router.post("/score", response_model=UserProfileV1_2_Extended)
async def score_user_profile(req: BuildUserProfileRequest) -> UserProfileV1_2_Extended:
    """
    根据问卷答案生成用户画像（V1.2）

    说明：
    - 问卷题目允许跳过
    - 允许注入 generated_at/now，用于回归测试或离线批处理
    """

    return build_user_profile_from_questionnaire(
        req.answers,
        generated_at=req.generated_at,
        now=req.now,
    )

