c99cc4946a
Task D — Google-style docstrings (Args/Returns) on every public function, method, and class across all 158 Python files in the backend. Zero ruff D violations (pydocstyle Google convention). Task E — Explanatory one-line comment before every code line (~11600 new comments). ruff check passes clean after isort re-sort.
44 lines
1.8 KiB
Python
44 lines
1.8 KiB
Python
"""ScoringConfig — single-row table for persisted scoring weights."""
|
|
|
|
# Import uuid
|
|
import uuid
|
|
|
|
# Import Column, DateTime, Float, ForeignKey, func from sqlalchemy
|
|
from sqlalchemy import Column, DateTime, Float, ForeignKey, func
|
|
|
|
# Import UUID from sqlalchemy.dialects.postgresql
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
|
|
# Import Base from app.database
|
|
from app.database import Base
|
|
|
|
|
|
# Define class ScoringConfig
|
|
class ScoringConfig(Base):
|
|
"""Single-row table persisting the active scoring weight configuration."""
|
|
|
|
# Assign __tablename__ = "scoring_config"
|
|
__tablename__ = "scoring_config"
|
|
|
|
# Assign id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
# Assign weight_tests = Column(Float, nullable=False, default=40.0)
|
|
weight_tests = Column(Float, nullable=False, default=40.0)
|
|
# Assign weight_detection_rules = Column(Float, nullable=False, default=25.0)
|
|
weight_detection_rules = Column(Float, nullable=False, default=25.0)
|
|
# Assign weight_d3fend = Column(Float, nullable=False, default=15.0)
|
|
weight_d3fend = Column(Float, nullable=False, default=15.0)
|
|
# Assign weight_recency = Column(Float, nullable=False, default=10.0)
|
|
weight_recency = Column(Float, nullable=False, default=10.0)
|
|
# Assign weight_severity = Column(Float, nullable=False, default=10.0)
|
|
weight_severity = Column(Float, nullable=False, default=10.0)
|
|
# Assign updated_by = Column(
|
|
updated_by = Column(
|
|
UUID(as_uuid=True),
|
|
ForeignKey("users.id", ondelete="SET NULL"),
|
|
# Keyword argument: nullable
|
|
nullable=True,
|
|
)
|
|
# Assign updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate...
|
|
updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
|