diff --git a/backend/app/schemas/chore_completion_log.py b/backend/app/schemas/chore_completion_log.py new file mode 100644 index 0000000..67e5d19 --- /dev/null +++ b/backend/app/schemas/chore_completion_log.py @@ -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]