Fix issues from QA review: cache invalidation, model server_default, route comment
- Add ['tracked-tasks'] cache invalidation to toggle mutations in ProjectDetail and ProjectCard so dashboard widget stays fresh - Add server_default=sa.false() to model for consistency with migration - Add route ordering comment above /tracked-tasks endpoint Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
819a4689b8
commit
bb87bd3743
@ -1,3 +1,4 @@
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import Boolean, String, Text, Date, func
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from datetime import datetime, date
|
||||
@ -14,7 +15,7 @@ class Project(Base):
|
||||
status: Mapped[str] = mapped_column(String(20), default="not_started")
|
||||
color: Mapped[Optional[str]] = mapped_column(String(20), nullable=True)
|
||||
due_date: Mapped[Optional[date]] = mapped_column(Date, nullable=True)
|
||||
is_tracked: Mapped[bool] = mapped_column(Boolean, default=False)
|
||||
is_tracked: Mapped[bool] = mapped_column(Boolean, default=False, server_default=sa.false())
|
||||
created_at: Mapped[datetime] = mapped_column(default=func.now())
|
||||
updated_at: Mapped[datetime] = mapped_column(default=func.now(), onupdate=func.now())
|
||||
|
||||
|
||||
@ -58,6 +58,7 @@ async def get_projects(
|
||||
return projects
|
||||
|
||||
|
||||
# This route MUST be defined before /{project_id} to avoid path parameter shadowing
|
||||
@router.get("/tracked-tasks", response_model=List[TrackedTaskResponse])
|
||||
async def get_tracked_tasks(
|
||||
days: int = Query(7, ge=1, le=90),
|
||||
|
||||
@ -42,6 +42,7 @@ export default function ProjectCard({ project }: ProjectCardProps) {
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['projects'] });
|
||||
queryClient.invalidateQueries({ queryKey: ['tracked-tasks'] });
|
||||
toast.success(project.is_tracked ? 'Project untracked' : 'Project tracked');
|
||||
},
|
||||
onError: () => {
|
||||
|
||||
@ -196,6 +196,7 @@ export default function ProjectDetail() {
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['projects'] });
|
||||
queryClient.invalidateQueries({ queryKey: ['projects', id] });
|
||||
queryClient.invalidateQueries({ queryKey: ['tracked-tasks'] });
|
||||
toast.success(project?.is_tracked ? 'Project untracked' : 'Project tracked');
|
||||
},
|
||||
onError: () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user