mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Scenario carries its Fabric First flag from the scenario table 🟥
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
d51801089b
commit
caa0847b70
3 changed files with 32 additions and 1 deletions
|
|
@ -26,7 +26,12 @@ class Scenario:
|
|||
|
||||
`exclusions` are the measure types the brief bars from the run (the only
|
||||
measure-scoping the live ``scenario`` table persists — there is no
|
||||
inclusions column). Empty means nothing is barred."""
|
||||
inclusions column). Empty means nothing is barred.
|
||||
|
||||
`fabric_first` constrains the Optimiser to treat the building envelope
|
||||
first: fabric measures are optimised with the full budget, and heating /
|
||||
renewables are only considered on top of the committed fabric when the
|
||||
fabric alone does not meet the brief's target."""
|
||||
|
||||
id: int
|
||||
goal: str
|
||||
|
|
@ -34,6 +39,7 @@ class Scenario:
|
|||
budget: Optional[float]
|
||||
is_default: bool
|
||||
exclusions: frozenset[MeasureType] = _NO_EXCLUSIONS
|
||||
fabric_first: bool = False
|
||||
|
||||
def considered_measures(self) -> Optional[frozenset[MeasureType]]:
|
||||
"""The measure-type allowlist the Scenario's exclusions imply: every
|
||||
|
|
|
|||
|
|
@ -78,6 +78,9 @@ class ScenarioModel(SQLModel, table=True):
|
|||
exclusions: Optional[str] = Field(default=None)
|
||||
multi_plan: bool = False
|
||||
is_default: bool = False
|
||||
# Fabric First constraint (owned by the FE Drizzle schema: boolean NOT
|
||||
# NULL DEFAULT false — do not deploy this mirror before that migration).
|
||||
fabric_first: bool = False
|
||||
|
||||
# Portfolio-level aggregates stored against the Scenario.
|
||||
cost: Optional[float] = Field(default=None)
|
||||
|
|
|
|||
|
|
@ -142,6 +142,28 @@ def test_get_many_raises_on_an_exclusion_that_is_not_a_measure_type(
|
|||
ScenarioPostgresRepository(session).get_many([7])
|
||||
|
||||
|
||||
def test_get_many_maps_the_fabric_first_flag(db_engine: Engine) -> None:
|
||||
# Arrange — a Fabric First brief created in the scenario-builder.
|
||||
with Session(db_engine) as session:
|
||||
session.add(
|
||||
ScenarioModel(
|
||||
id=7,
|
||||
goal=PortfolioGoal.INCREASING_EPC,
|
||||
goal_value="C",
|
||||
is_default=True,
|
||||
fabric_first=True,
|
||||
)
|
||||
)
|
||||
session.commit()
|
||||
|
||||
# Act
|
||||
with Session(db_engine) as session:
|
||||
scenario: Scenario = ScenarioPostgresRepository(session).get_many([7])[0]
|
||||
|
||||
# Assert
|
||||
assert scenario.fabric_first is True
|
||||
|
||||
|
||||
def test_get_many_raises_when_a_scenario_id_is_missing(db_engine: Engine) -> None:
|
||||
# Arrange
|
||||
with Session(db_engine) as session:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue