Phase 3.1: Enhanced Chore Logging and Reporting System
This commit is contained in:
31
backend/app/models/chore_completion_log.py
Normal file
31
backend/app/models/chore_completion_log.py
Normal file
@@ -0,0 +1,31 @@
|
||||
"""Chore Completion Log model for tracking historical chore completions."""
|
||||
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, Text
|
||||
from sqlalchemy.orm import relationship
|
||||
from datetime import datetime
|
||||
from app.core.database import Base
|
||||
|
||||
|
||||
class ChoreCompletionLog(Base):
|
||||
"""
|
||||
Comprehensive log of chore completions.
|
||||
|
||||
This model tracks every completion instance, allowing for:
|
||||
- Historical completion data
|
||||
- Multiple completions of the same chore
|
||||
- Optional notes and verification
|
||||
- Weekly/monthly reporting
|
||||
"""
|
||||
__tablename__ = "chore_completion_logs"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
chore_id = Column(Integer, ForeignKey("chores.id", ondelete="CASCADE"), nullable=False, index=True)
|
||||
user_id = Column(Integer, ForeignKey("users.id", ondelete="CASCADE"), nullable=False, index=True)
|
||||
completed_at = Column(DateTime, default=datetime.utcnow, nullable=False, index=True)
|
||||
notes = Column(Text, nullable=True) # Optional notes about the completion
|
||||
verified_by_user_id = Column(Integer, ForeignKey("users.id", ondelete="SET NULL"), nullable=True) # Optional verification
|
||||
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
|
||||
# Relationships
|
||||
chore = relationship("Chore", foreign_keys=[chore_id])
|
||||
user = relationship("User", foreign_keys=[user_id], back_populates="chore_completion_logs")
|
||||
verified_by = relationship("User", foreign_keys=[verified_by_user_id])
|
||||
Reference in New Issue
Block a user