mitlist/be/app/schemas/activity.py
mohamad 229f6b7b1c feat: Introduce activity tracking and management features
This commit adds new functionality for tracking user activities within the application, including:

- Implementation of a new activity service to fetch and manage group activities.
- Creation of a dedicated activity store to handle state management for activities.
- Introduction of new API endpoints for retrieving paginated activity data.
- Enhancements to the UI with new components for displaying activity feeds and items.
- Refactoring of existing components to utilize the new activity features, improving user engagement and interaction.

These changes aim to enhance the application's activity tracking capabilities and provide users with a comprehensive view of their interactions.
2025-06-28 19:14:51 +02:00

32 lines
1.1 KiB
Python

from pydantic import BaseModel, Field
from datetime import datetime
from enum import Enum
from typing import Optional, Dict, Any, List
class ActivityEventType(str, Enum):
CHORE_COMPLETED = "chore_completed"
CHORE_CREATED = "chore_created"
EXPENSE_CREATED = "expense_created"
EXPENSE_SETTLED = "expense_settled"
ITEM_ADDED = "item_added"
ITEM_COMPLETED = "item_completed"
USER_JOINED_GROUP = "user_joined_group"
class ActivityUser(BaseModel):
id: int
name: Optional[str] = None
class Activity(BaseModel):
id: str = Field(..., description="A unique ID for the activity event, e.g., 'chore_completed-123'")
event_type: ActivityEventType
timestamp: datetime
user: ActivityUser
details: Dict[str, Any] = Field({}, description="Structured data about the event.")
message: str = Field(..., description="A human-readable message, e.g., 'John completed \"Wash dishes\".'")
class Config:
from_attributes = True
class PaginatedActivityResponse(BaseModel):
items: List[Activity]
cursor: Optional[int] = Field(None, description="The timestamp of the last item, for cursor-based pagination.")