e62ece1c06
- FastAPI app with CORS, lifespan handlers - Pydantic Settings config (DB, Redis, CORS, SMTP, JWT, Rentman) - SQLAlchemy async engine + session (DeclarativeBase) - 6 DB models: EquipmentCache, RentalRequest, RentalRequestItem, Contact, AdminUser, SyncLog - Pydantic schemas: EquipmentItem, EquipmentDetail, PaginatedEquipment, ContactCreate, ContactResponse - Redis cache helper: set/get/delete_pattern, rate limiting, equipment key builders - Equipment router: list (search/category/sort/pagination), detail, categories – all cached - Contact router: POST with Pydantic validation + rate limiting (5/min) - Health router: GET /api/health with DB + Redis status - 28 pytest tests (all pass, 90% coverage) - Dockerfile, requirements.txt, pytest.ini, test_report.md
28 lines
1.0 KiB
Python
28 lines
1.0 KiB
Python
"""SyncLog SQLAlchemy model."""
|
|
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import DateTime, Index, Integer, String, Text, func
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.database import Base
|
|
|
|
|
|
class SyncLog(Base):
|
|
"""Log entry for equipment sync operations."""
|
|
|
|
__tablename__ = "sync_log"
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
sync_type: Mapped[str] = mapped_column(String(32), default="equipment", nullable=False)
|
|
status: Mapped[str] = mapped_column(String(32), nullable=False)
|
|
items_processed: Mapped[int] = mapped_column(Integer, default=0, nullable=False)
|
|
items_failed: Mapped[int] = mapped_column(Integer, default=0, nullable=False)
|
|
error_message: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
started_at: Mapped[datetime] = mapped_column(server_default=func.now(), nullable=False)
|
|
completed_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
|
|
|
__table_args__ = (
|
|
Index("idx_sync_log_started", "started_at"),
|
|
)
|