P-01: Clamp delta poll since param to max 24h in the past (projects + calendars) to prevent expensive full-table scans from malicious timestamps. P-02: Validate individual user_id elements in ProjectMemberInvite and TaskAssignmentCreate with Annotated[int, Field(ge=1, le=2147483647)]. P-04: Only enable delta polling for shared projects (member_count > 0). Solo projects skip the 5s poll entirely. P-05: Remove fragile 200ms onBlur timeout in ProjectShareSheet search. The onMouseDown preventDefault on dropdown items already prevents blur from firing before click registers. P-06/S-04: Replace manual dict construction in model_validators with __table__.columns iteration so new fields are auto-included. S-01: Replace bare except in ProjectResponse.compute_member_count with logger.debug to surface errors in development. S-03: Consolidate cascade_projects_on_disconnect from 2 project ID queries into 1 using IN clause with both user IDs. S-05: Send version in toggleTaskMutation, updateTaskStatusMutation, and toggleSubtaskMutation for full optimistic locking coverage. Handle 409 with refresh toast. S-07: Replace window.location.href with React Router navigateRef in task_assigned toast for client-side navigation. S-08: Already fixed in previous commit (subtask comment selectinload). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
from typing import Annotated
|
|
from pydantic import BaseModel, ConfigDict, Field, model_validator
|
|
from datetime import datetime
|
|
|
|
|
|
class TaskAssignmentCreate(BaseModel):
|
|
model_config = ConfigDict(extra="forbid")
|
|
|
|
user_ids: list[Annotated[int, Field(ge=1, le=2147483647)]] = Field(min_length=1, max_length=20)
|
|
|
|
|
|
class TaskAssignmentResponse(BaseModel):
|
|
id: int
|
|
task_id: int
|
|
user_id: int
|
|
assigned_by: int
|
|
user_name: str | None = None
|
|
created_at: datetime
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
@model_validator(mode="before")
|
|
@classmethod
|
|
def resolve_user_name(cls, data): # type: ignore[override]
|
|
"""Populate user_name from eagerly loaded user relationship."""
|
|
if hasattr(data, "user") and data.user is not None and not getattr(data, "user_name", None):
|
|
# Build dict from ORM columns so new fields are auto-included
|
|
cols = {c.key: getattr(data, c.key) for c in data.__table__.columns}
|
|
cols["user_name"] = data.user.username
|
|
return cols
|
|
return data
|