Automated Action 53d9909fb6 Create gamified kids learning API with FastAPI and SQLite
- Set up project structure with FastAPI and SQLite
- Implement user authentication with JWT
- Create models for learning content (subjects, lessons, quizzes)
- Add progress tracking and gamification features
- Implement comprehensive API documentation
- Add error handling and validation
- Set up proper logging and health check endpoint
2025-06-17 18:25:16 +00:00

34 lines
902 B
Python

from __future__ import annotations
from typing import List, Optional
from sqlalchemy.orm import Session
from app.models.content import Subject
from app.schemas.content import SubjectCreate, SubjectUpdate
from app.utils.db import CRUDBase
class CRUDSubject(CRUDBase[Subject, SubjectCreate, SubjectUpdate]):
def get_by_name(self, db: Session, *, name: str) -> Optional[Subject]:
"""
Get a subject by name.
"""
return db.query(Subject).filter(Subject.name == name).first()
def get_active(self, db: Session, *, skip: int = 0, limit: int = 100) -> List[Subject]:
"""
Get active subjects.
"""
return (
db.query(Subject)
.filter(Subject.is_active == True)
.order_by(Subject.order)
.offset(skip)
.limit(limit)
.all()
)
subject = CRUDSubject(Subject)