- Event-based triggers (Phase 1): - Trigger/TriggerLog models with field_change type - TriggerService for condition evaluation and action execution - Trigger CRUD API endpoints - Task integration (status, assignee, priority changes) - Frontend: TriggerList, TriggerForm components - Weekly reports (Phase 2): - ScheduledReport/ReportHistory models - ReportService for stats generation - APScheduler for Friday 16:00 job - Report preview/generate/history API - Frontend: WeeklyReportPreview, ReportHistory components - Tests: 23 new tests (14 triggers + 9 reports) - OpenSpec: add-automation change archived 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
29 lines
1016 B
Python
29 lines
1016 B
Python
import uuid
|
|
import enum
|
|
from sqlalchemy import Column, String, Boolean, DateTime, ForeignKey, Enum
|
|
from sqlalchemy.sql import func
|
|
from sqlalchemy.orm import relationship
|
|
from app.core.database import Base
|
|
|
|
|
|
class ReportType(str, enum.Enum):
|
|
WEEKLY = "weekly"
|
|
|
|
|
|
class ScheduledReport(Base):
|
|
__tablename__ = "pjctrl_scheduled_reports"
|
|
|
|
id = Column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
|
|
report_type = Column(
|
|
Enum("weekly", name="report_type_enum"),
|
|
nullable=False
|
|
)
|
|
recipient_id = Column(String(36), ForeignKey("pjctrl_users.id", ondelete="CASCADE"), nullable=False)
|
|
is_active = Column(Boolean, default=True, nullable=False)
|
|
last_sent_at = Column(DateTime, nullable=True)
|
|
created_at = Column(DateTime, server_default=func.now(), nullable=False)
|
|
|
|
# Relationships
|
|
recipient = relationship("User", back_populates="scheduled_reports")
|
|
history = relationship("ReportHistory", back_populates="report", cascade="all, delete-orphan")
|