feat(sector-radar): add weighted scores and rank-change views
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
"""Keep weighted ranking scores separate from raw flow values."""
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
revision = "0010_radar_weighted_score"
|
||||
down_revision = "0009_radar_sector_detail"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Preserve existing publication rows with an unknown (NULL) score."""
|
||||
op.add_column(
|
||||
"sector_radar_ranking", sa.Column("weighted_score", sa.Numeric(28, 12), nullable=True)
|
||||
)
|
||||
op.create_check_constraint(
|
||||
"ck_radar_weighted_score_finite",
|
||||
"sector_radar_ranking",
|
||||
"weighted_score IS NULL OR weighted_score NOT IN "
|
||||
"('NaN'::numeric, 'Infinity'::numeric, '-Infinity'::numeric)",
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Remove the additional score projection without changing raw values."""
|
||||
op.drop_column("sector_radar_ranking", "weighted_score")
|
||||
Reference in New Issue
Block a user