f38ec177d7
이론공부 개선 B→A→C 의 A. 개념노트를 구조(요약/본문/빈출★/관련개념)로 렌더 + 능동 회상(떠올리기) + 관련개념 백링크 + 이전/다음.
- concept_parser: md 골격 파서(273/273 불변식) + 관련개념 백링크 해소(exact→title⊆phrase substring, 과대매치 가드)
- concept_curriculum.concept_detail + GET /api/study/concepts/{id} (개념문서 태그 스코프)
- /study/read/[docId] 리더(MarkdownDoc KaTeX+docimg 재사용·읽기/떠올리기 모드) + 홈 오늘의개념 링크 연결
- 적대리뷰 5건 반영(이중로드·substring 오결선·엔드포인트 스코프·prev/next 결정성·in-flight 가드). 마이그 없음·문제풀이 무접촉
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
69 lines
2.4 KiB
Python
69 lines
2.4 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, HTTPException
|
|
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.get("/concepts/{doc_id}")
|
|
async def get_concept_detail(
|
|
doc_id: int,
|
|
user: Annotated[User, Depends(get_current_user)],
|
|
session: Annotated[AsyncSession, Depends(get_session)],
|
|
topic_id: int = DEFAULT_TOPIC_ID,
|
|
):
|
|
"""개념 리더 재료 — 구조 파싱(요약/본문/빈출/관련) + 백링크 해소 + 회독/SR + 이전/다음."""
|
|
detail = await cc.concept_detail(session, user.id, topic_id, doc_id)
|
|
if detail is None:
|
|
raise HTTPException(status_code=404, detail="concept not found")
|
|
return detail
|
|
|
|
|
|
@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)
|