feat: initial project setup

This commit is contained in:
Stijnvandenbroek
2026-03-06 12:25:07 +00:00
commit e1a67da3ce
33 changed files with 2069 additions and 0 deletions

44
backend/app/models.py Normal file
View File

@@ -0,0 +1,44 @@
"""SQLAlchemy ORM models for ELO rating tables."""
from sqlalchemy import Column, DateTime, Float, Integer, String
from sqlalchemy.sql import func
from app.config import settings
from app.database import Base
class EloRating(Base):
"""Tracks the current ELO rating for each listing."""
__tablename__ = "ratings"
__table_args__ = {"schema": settings.ELO_SCHEMA}
global_id = Column(String, primary_key=True)
elo_rating = Column(Float, nullable=False, default=settings.DEFAULT_ELO)
comparison_count = Column(Integer, nullable=False, default=0)
wins = Column(Integer, nullable=False, default=0)
losses = Column(Integer, nullable=False, default=0)
created_at = Column(DateTime(timezone=True), server_default=func.now())
updated_at = Column(
DateTime(timezone=True), server_default=func.now(), onupdate=func.now()
)
class Comparison(Base):
"""Records each pairwise comparison with ELO snapshots."""
__tablename__ = "comparisons"
__table_args__ = {"schema": settings.ELO_SCHEMA}
id = Column(Integer, primary_key=True, autoincrement=True)
listing_a_id = Column(String, nullable=False)
listing_b_id = Column(String, nullable=False)
winner_id = Column(String, nullable=False)
elo_a_before = Column(Float, nullable=False)
elo_b_before = Column(Float, nullable=False)
elo_a_after = Column(Float, nullable=False)
elo_b_after = Column(Float, nullable=False)
created_at = Column(DateTime(timezone=True), server_default=func.now())