"""ScoringConfig — single-row table for persisted scoring weights."""

import uuid

from sqlalchemy import Column, Float, DateTime, ForeignKey, func
from sqlalchemy.dialects.postgresql import UUID

from app.database import Base


class ScoringConfig(Base):
    __tablename__ = "scoring_config"

    id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
    weight_tests = Column(Float, nullable=False, default=40.0)
    weight_detection_rules = Column(Float, nullable=False, default=25.0)
    weight_d3fend = Column(Float, nullable=False, default=15.0)
    weight_recency = Column(Float, nullable=False, default=10.0)
    weight_severity = Column(Float, nullable=False, default=10.0)
    updated_by = Column(
        UUID(as_uuid=True),
        ForeignKey("users.id", ondelete="SET NULL"),
        nullable=True,
    )
    updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
