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:
@@ -6,6 +6,7 @@ from app.models.subject import Subject, SubjectOption
|
||||
from app.models.schedule import ScheduleTemplate, ScheduleBlock
|
||||
from app.models.session import DailySession, TimerEvent, TimerEventType
|
||||
from app.models.activity import ActivityLog
|
||||
from app.models.strike import StrikeEvent
|
||||
|
||||
__all__ = [
|
||||
"Base",
|
||||
@@ -20,4 +21,5 @@ __all__ = [
|
||||
"TimerEvent",
|
||||
"TimerEventType",
|
||||
"ActivityLog",
|
||||
"StrikeEvent",
|
||||
]
|
||||
|
||||
18
backend/app/models/strike.py
Normal file
18
backend/app/models/strike.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import DateTime, ForeignKey, Integer, func
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.models.base import Base
|
||||
|
||||
|
||||
class StrikeEvent(Base):
|
||||
__tablename__ = "strike_events"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
||||
child_id: Mapped[int] = mapped_column(ForeignKey("children.id", ondelete="CASCADE"), nullable=False)
|
||||
occurred_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), nullable=False)
|
||||
prev_strikes: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
new_strikes: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
child: Mapped["Child"] = relationship("Child") # noqa: F821
|
||||
Reference in New Issue
Block a user