da4a2e81c3
개념문서(가스기사 289) 소비 표면 개선 1단계. /study 허브를 데일리 랜딩으로.
- 마이그 381 study_concept_progress (개념 SR, sr_schedule 공용, documents FK 없음=락 회피)
- concept_curriculum 서비스 + /api/study (curriculum·today-concepts·concepts/{id}/read)
- read 상태 정본 = document_reads (is_read 컬럼 아님), mark_read=회독+SR 입고
- 문제풀이 표면 무접촉·additive
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
55 lines
1.8 KiB
Python
55 lines
1.8 KiB
Python
"""study_concepts API — 이론공부 홈(오늘의 개념 · 진도 · 회독 SR). prefix = /api/study.
|
|
|
|
문제풀이 표면 무접촉. 개념문서(가스기사 태그) 읽기 집계 + 회독 SR write 만. 단일 토픽(가스기사=4).
|
|
경로: GET /curriculum · GET /today-concepts · POST /concepts/{doc_id}/read.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Annotated
|
|
|
|
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from core.auth import get_current_user
|
|
from core.database import get_session
|
|
from models.user import User
|
|
from services.study import concept_curriculum as cc
|
|
|
|
router = APIRouter()
|
|
|
|
# 가스기사 단일 토픽 운영(현행). 다토픽 확장 시 쿼리 파라미터로 승격.
|
|
DEFAULT_TOPIC_ID = 4
|
|
|
|
|
|
@router.get("/curriculum")
|
|
async def get_curriculum(
|
|
user: Annotated[User, Depends(get_current_user)],
|
|
session: Annotated[AsyncSession, Depends(get_session)],
|
|
topic_id: int = DEFAULT_TOPIC_ID,
|
|
):
|
|
"""과목별 회독 진도 + 개념/문항 복습 due 요약."""
|
|
return await cc.curriculum(session, user.id, topic_id)
|
|
|
|
|
|
@router.get("/today-concepts")
|
|
async def get_today_concepts(
|
|
user: Annotated[User, Depends(get_current_user)],
|
|
session: Annotated[AsyncSession, Depends(get_session)],
|
|
topic_id: int = DEFAULT_TOPIC_ID,
|
|
limit: int = 6,
|
|
):
|
|
"""오늘 공부할 개념(재복습 → 미독 빈출순)."""
|
|
return await cc.today_concepts(session, user.id, topic_id, limit)
|
|
|
|
|
|
@router.post("/concepts/{doc_id}/read")
|
|
async def post_concept_read(
|
|
doc_id: int,
|
|
user: Annotated[User, Depends(get_current_user)],
|
|
session: Annotated[AsyncSession, Depends(get_session)],
|
|
topic_id: int = DEFAULT_TOPIC_ID,
|
|
):
|
|
"""개념 회독 처리 → 회독 플래그 + SR 입고/전진."""
|
|
return await cc.mark_read(session, user.id, topic_id, doc_id)
|