Add strike events to activity log

Record a StrikeEvent row whenever a strike is added or removed,
and surface them in the activity log timeline with timestamp,
child name, and whether the strike was added or removed.

- New strike_events table (auto-created on startup)
- children router records prev/new strikes on every update
- GET /api/logs/strikes and DELETE /api/logs/strikes/:id endpoints
- Log view merges strike entries into the timeline (red dot,
  "✕ Strike added (2/3)" / "↩ Strike removed (1/3)")

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-01 22:07:41 -08:00
parent f730e9edf9
commit b5f4188396
6 changed files with 127 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
from datetime import date, datetime, timezone
from pydantic import BaseModel, field_serializer
from pydantic import BaseModel, computed_field, field_serializer
class ActivityLogCreate(BaseModel):
@@ -51,3 +51,21 @@ class TimelineEventOut(BaseModel):
if dt.tzinfo is None:
dt = dt.replace(tzinfo=timezone.utc)
return dt.isoformat()
class StrikeEventOut(BaseModel):
id: int
child_id: int
child_name: str
occurred_at: datetime
log_date: date
prev_strikes: int
new_strikes: int
model_config = {"from_attributes": True}
@field_serializer("occurred_at")
def serialize_occurred_at(self, dt: datetime) -> str:
if dt.tzinfo is None:
dt = dt.replace(tzinfo=timezone.utc)
return dt.isoformat()