"""Analytics DTOs — Phase 12.8."""
from __future__ import annotations

from datetime import datetime
from uuid import UUID

from pydantic import BaseModel, Field

from app.models.types import LifecycleStatus
from app.schemas.common import ORMBase


class AnalyticsReportDefinitionCreate(BaseModel):
    venue_id: UUID | None = None
    code: str = Field(max_length=50)
    name: str = Field(max_length=255)
    metric_keys: list[str]
    filters: dict | None = None
    status: LifecycleStatus = LifecycleStatus.ACTIVE


class AnalyticsReportDefinitionRead(ORMBase):
    id: UUID
    tenant_id: UUID
    venue_id: UUID | None
    code: str
    name: str
    metric_keys: list[str]
    filters: dict | None
    status: LifecycleStatus
    is_deleted: bool
    created_by: str | None
    updated_by: str | None
    created_at: datetime
    updated_at: datetime


class AnalyticsSnapshotRefresh(BaseModel):
    report_id: UUID
    venue_id: UUID | None = None
    period_start: str = Field(max_length=32)
    period_end: str = Field(max_length=32)


class AnalyticsSnapshotRead(ORMBase):
    id: UUID
    tenant_id: UUID
    venue_id: UUID | None
    report_id: UUID
    period_start: str
    period_end: str
    metrics: dict
    status: LifecycleStatus
    is_deleted: bool
    created_by: str | None
    updated_by: str | None
    created_at: datetime
    updated_at: datetime
