Backend: SQLAlchemy models, Alembic migrations, requirements lockfile. Frontend: pinned deps, package-lock, vite-env types fix. Verified compose build/health, pytest, ruff clean.
36 lines
1.5 KiB
Python
36 lines
1.5 KiB
Python
import uuid
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import DateTime, String
|
|
from sqlalchemy.dialects.postgresql import JSONB, UUID
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.core.db import Base
|
|
from app.models.mixins import TimestampMixin, UUIDPrimaryKeyMixin
|
|
|
|
RULE_TYPES = (
|
|
"possible_duplicate_customer",
|
|
"missing_required_field",
|
|
"odometer_regression",
|
|
"booking_overlap",
|
|
"vehicle_status_conflict",
|
|
)
|
|
SEVERITIES = ("low", "medium", "high")
|
|
ISSUE_STATUSES = ("open", "deferred", "resolved", "rejected")
|
|
|
|
|
|
class DataQualityIssue(UUIDPrimaryKeyMixin, TimestampMixin, Base):
|
|
__tablename__ = "data_quality_issues"
|
|
|
|
public_ref: Mapped[str] = mapped_column(String(20), unique=True, nullable=False)
|
|
rule_type: Mapped[str] = mapped_column(String(40), nullable=False)
|
|
entity_type: Mapped[str] = mapped_column(String(30), nullable=False)
|
|
entity_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), nullable=False)
|
|
severity: Mapped[str] = mapped_column(String(10), nullable=False)
|
|
status: Mapped[str] = mapped_column(String(20), nullable=False, default="open")
|
|
evidence_json: Mapped[dict] = mapped_column(JSONB, nullable=False, default=dict)
|
|
proposed_action_json: Mapped[dict] = mapped_column(JSONB, nullable=False, default=dict)
|
|
detected_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False)
|
|
resolved_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True))
|
|
resolved_by: Mapped[str | None] = mapped_column(String(120))
|