Backend: - Add reset_at (datetime) and next_due_date (date) columns to todos - Toggle endpoint calculates reset schedule when completing recurring todos: daily resets next day, weekly resets start of next week (respects first_day_of_week setting), monthly resets 1st of next month - GET /todos auto-reactivates recurring todos whose reset_at has passed, updating due_date to next_due_date and clearing completion state - Alembic migration 014 Frontend: - Add reset_at and next_due_date to Todo type - TodoItem shows recurrence badge (Daily/Weekly/Monthly) in purple - Completed recurring todos display reset info: "Resets Mon 02/03/26 · Next due 06/03/26" Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
28 lines
1.4 KiB
Python
28 lines
1.4 KiB
Python
from sqlalchemy import String, Text, Boolean, Date, Integer, ForeignKey, func
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
from datetime import datetime, date
|
|
from typing import Optional
|
|
from app.database import Base
|
|
|
|
|
|
class Todo(Base):
|
|
__tablename__ = "todos"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True, index=True)
|
|
title: Mapped[str] = mapped_column(String(255), nullable=False)
|
|
description: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
|
priority: Mapped[str] = mapped_column(String(20), default="medium")
|
|
due_date: Mapped[Optional[date]] = mapped_column(Date, nullable=True)
|
|
completed: Mapped[bool] = mapped_column(Boolean, default=False)
|
|
completed_at: Mapped[Optional[datetime]] = mapped_column(nullable=True)
|
|
category: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
|
|
recurrence_rule: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
|
|
reset_at: Mapped[Optional[datetime]] = mapped_column(nullable=True)
|
|
next_due_date: Mapped[Optional[date]] = mapped_column(Date, nullable=True)
|
|
project_id: Mapped[Optional[int]] = mapped_column(Integer, ForeignKey("projects.id"), nullable=True)
|
|
created_at: Mapped[datetime] = mapped_column(default=func.now())
|
|
updated_at: Mapped[datetime] = mapped_column(default=func.now(), onupdate=func.now())
|
|
|
|
# Relationships
|
|
project: Mapped[Optional["Project"]] = relationship(back_populates="todos")
|