- 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
942 B
Python
29 lines
942 B
Python
import uuid
|
|
import enum
|
|
from sqlalchemy import Column, String, Text, DateTime, ForeignKey, Enum, JSON
|
|
from sqlalchemy.sql import func
|
|
from sqlalchemy.orm import relationship
|
|
from app.core.database import Base
|
|
|
|
|
|
class ReportHistoryStatus(str, enum.Enum):
|
|
SENT = "sent"
|
|
FAILED = "failed"
|
|
|
|
|
|
class ReportHistory(Base):
|
|
__tablename__ = "pjctrl_report_history"
|
|
|
|
id = Column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
|
|
report_id = Column(String(36), ForeignKey("pjctrl_scheduled_reports.id", ondelete="CASCADE"), nullable=False)
|
|
generated_at = Column(DateTime, server_default=func.now(), nullable=False)
|
|
content = Column(JSON, nullable=False)
|
|
status = Column(
|
|
Enum("sent", "failed", name="report_history_status_enum"),
|
|
nullable=False
|
|
)
|
|
error_message = Column(Text, nullable=True)
|
|
|
|
# Relationships
|
|
report = relationship("ScheduledReport", back_populates="history")
|