- Implemented Pomodoro timer in the app, allowing users to start, pause, and stop sessions. - Added context for managing Pomodoro state and actions. - Integrated time logging for completed sessions to track productivity. - Enhanced project settings to include time goals and Pomodoro settings. - Created migration scripts to update the database schema for new project fields and time logs. - Updated UI components to display Pomodoro controls and project time summaries. - Added category filtering for projects in the project list view.
62 lines
2.6 KiB
Python
62 lines
2.6 KiB
Python
from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey, JSON, Boolean
|
|
from sqlalchemy.orm import relationship
|
|
from datetime import datetime
|
|
from .database import Base
|
|
|
|
|
|
# Default statuses for new projects
|
|
DEFAULT_STATUSES = ["backlog", "in_progress", "on_hold", "done"]
|
|
|
|
|
|
class Project(Base):
|
|
__tablename__ = "projects"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
name = Column(String(255), nullable=False)
|
|
description = Column(Text, nullable=True)
|
|
statuses = Column(JSON, nullable=False, default=DEFAULT_STATUSES)
|
|
is_archived = Column(Boolean, default=False, nullable=False)
|
|
category = Column(String(100), nullable=True)
|
|
weekly_hours_goal = Column(Integer, nullable=True) # stored in minutes
|
|
total_hours_goal = Column(Integer, nullable=True) # stored in minutes
|
|
pomodoro_work_minutes = Column(Integer, nullable=True, default=25)
|
|
pomodoro_break_minutes = Column(Integer, nullable=True, default=5)
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
|
|
|
tasks = relationship("Task", back_populates="project", cascade="all, delete-orphan")
|
|
|
|
|
|
class Task(Base):
|
|
__tablename__ = "tasks"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
project_id = Column(Integer, ForeignKey("projects.id"), nullable=False)
|
|
parent_task_id = Column(Integer, ForeignKey("tasks.id"), nullable=True)
|
|
title = Column(String(500), nullable=False)
|
|
description = Column(Text, nullable=True)
|
|
status = Column(String(50), default="backlog", nullable=False)
|
|
sort_order = Column(Integer, default=0)
|
|
estimated_minutes = Column(Integer, nullable=True)
|
|
tags = Column(JSON, nullable=True)
|
|
flag_color = Column(String(50), nullable=True)
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
|
|
|
project = relationship("Project", back_populates="tasks")
|
|
parent = relationship("Task", remote_side=[id], backref="subtasks")
|
|
time_logs = relationship("TimeLog", back_populates="task", cascade="all, delete-orphan")
|
|
|
|
|
|
class TimeLog(Base):
|
|
__tablename__ = "time_logs"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
task_id = Column(Integer, ForeignKey("tasks.id"), nullable=False)
|
|
minutes = Column(Integer, nullable=False)
|
|
note = Column(Text, nullable=True)
|
|
session_type = Column(String(50), default="manual") # 'pomodoro' | 'manual'
|
|
logged_at = Column(DateTime, default=datetime.utcnow)
|
|
|
|
task = relationship("Task", back_populates="time_logs")
|