Phase 3.1: Enhanced Chore Logging and Reporting System

This commit is contained in:
2026-02-05 12:33:51 +11:00
commit e3cae7bfbb
178 changed files with 30105 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
"""Schemas for Chore Completion Logs."""
from pydantic import BaseModel, Field
from datetime import datetime
from typing import Optional
class ChoreCompletionLogBase(BaseModel):
"""Base schema for chore completion log."""
notes: Optional[str] = Field(None, description="Optional notes about the completion")
class ChoreCompletionLogCreate(ChoreCompletionLogBase):
"""Schema for creating a chore completion log."""
chore_id: int = Field(..., description="ID of the chore being completed")
user_id: int = Field(..., description="ID of the user completing the chore")
completed_at: Optional[datetime] = Field(None, description="When the chore was completed (defaults to now)")
class ChoreCompletionLogUpdate(BaseModel):
"""Schema for updating a chore completion log."""
notes: Optional[str] = Field(None, description="Update notes about the completion")
verified_by_user_id: Optional[int] = Field(None, description="ID of user verifying the completion")
class ChoreCompletionLog(ChoreCompletionLogBase):
"""Schema for chore completion log response."""
id: int
chore_id: int
user_id: int
completed_at: datetime
verified_by_user_id: Optional[int] = None
created_at: datetime
# Nested objects for expanded responses
chore_title: Optional[str] = None
user_name: Optional[str] = None
user_avatar: Optional[str] = None
verified_by_name: Optional[str] = None
class Config:
from_attributes = True
class WeeklyChoreReport(BaseModel):
"""Schema for weekly chore completion report."""
start_date: datetime
end_date: datetime
total_completions: int
completions_by_user: dict[str, int] # {username: count}
completions_by_chore: dict[str, int] # {chore_title: count}
completions_by_day: dict[str, int] # {day: count}
top_performers: list[dict] # [{username, count, avatar_url}]
recent_completions: list[ChoreCompletionLog]
class UserChoreStats(BaseModel):
"""Schema for user-specific chore statistics."""
user_id: int
username: str
full_name: Optional[str] = None
avatar_url: Optional[str] = None
total_completions: int
completions_this_week: int
completions_this_month: int
favorite_chore: Optional[str] = None
recent_completions: list[ChoreCompletionLog]