
- Added completion_date field to Todo model - Modified CRUD to auto-set completion_date when task is marked complete - Added completion date stats (last 24h, last week metrics) - Created Alembic migration for the new field - Updated API documentation and README generated with BackendIM... (backend.im)
24 lines
890 B
Python
24 lines
890 B
Python
from sqlalchemy import Column, Integer, String, Boolean, DateTime, Enum
|
|
from sqlalchemy.sql import func
|
|
import enum
|
|
|
|
from app.db.base import Base
|
|
|
|
class PriorityEnum(enum.Enum):
|
|
LOW = "low"
|
|
MEDIUM = "medium"
|
|
HIGH = "high"
|
|
|
|
class Todo(Base):
|
|
__tablename__ = "todos"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
title = Column(String, index=True)
|
|
description = Column(String, nullable=True)
|
|
completed = Column(Boolean, default=False)
|
|
category = Column(String, nullable=True, index=True)
|
|
priority = Column(Enum(PriorityEnum), default=PriorityEnum.MEDIUM, nullable=True)
|
|
due_date = Column(DateTime(timezone=True), nullable=True)
|
|
completion_date = Column(DateTime(timezone=True), nullable=True)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), onupdate=func.now()) |