Automated Action ba478ce2d3 Implement Task Manager API with FastAPI and SQLite
Create a full-featured task management API with the following components:
- RESTful CRUD operations for tasks
- Task status and priority management
- SQLite database with SQLAlchemy ORM
- Alembic migrations
- Health check endpoint
- Comprehensive API documentation
2025-05-30 22:50:55 +00:00

46 lines
1.1 KiB
Python

"""
CRUD operations for tasks.
"""
from typing import List
from sqlalchemy.orm import Session
from app.crud.base import CRUDBase
from app.models.task import Task, TaskStatus
from app.schemas.task import TaskCreate, TaskUpdate
class CRUDTask(CRUDBase[Task, TaskCreate, TaskUpdate]):
"""
CRUD operations for tasks.
"""
def get_by_status(
self, db: Session, *, status: TaskStatus, skip: int = 0, limit: int = 100
) -> List[Task]:
"""
Get tasks by status.
"""
return (
db.query(self.model)
.filter(self.model.status == status)
.offset(skip)
.limit(limit)
.all()
)
def get_by_title(
self, db: Session, *, title: str, skip: int = 0, limit: int = 100
) -> List[Task]:
"""
Get tasks by title (partial match).
"""
return (
db.query(self.model)
.filter(self.model.title.ilike(f"%{title}%"))
.offset(skip)
.limit(limit)
.all()
)
task = CRUDTask(Task)