mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
make sure Plan object is instantiated correctly. Additional logging
This commit is contained in:
parent
96fbd7f24c
commit
325e7f65e0
1 changed files with 11 additions and 1 deletions
|
|
@ -46,6 +46,8 @@ def process_portfolio(
|
||||||
if plan.id is not None: # just in case
|
if plan.id is not None: # just in case
|
||||||
plans_by_id[plan.id] = plan
|
plans_by_id[plan.id] = plan
|
||||||
|
|
||||||
|
logger.info(f"Successfully unset {len(default_plans)} default plan(s)")
|
||||||
|
|
||||||
# then set new defaults on domain objects under consideration
|
# then set new defaults on domain objects under consideration
|
||||||
plans_for_consideration_by_property: Dict[int, List[Plan]] = (
|
plans_for_consideration_by_property: Dict[int, List[Plan]] = (
|
||||||
_group_plans_by_property(plans_for_consideration)
|
_group_plans_by_property(plans_for_consideration)
|
||||||
|
|
@ -68,8 +70,11 @@ def process_portfolio(
|
||||||
if plan.id is not None: # just in case
|
if plan.id is not None: # just in case
|
||||||
plans_by_id[plan.id] = plan
|
plans_by_id[plan.id] = plan
|
||||||
|
|
||||||
|
logger.info("Successfully set defaults on Plan objects in memory")
|
||||||
|
|
||||||
# then pass all domain objects to database to update (regardless of whether they've changed)
|
# then pass all domain objects to database to update (regardless of whether they've changed)
|
||||||
_update_plans_in_db(list(plans_by_id.values()))
|
_update_plans_in_db(list(plans_by_id.values()))
|
||||||
|
logger.info(f"Successfully updated {len(plans_by_id)} Plans in database")
|
||||||
|
|
||||||
|
|
||||||
def choose_cheapest_relevant_plan(
|
def choose_cheapest_relevant_plan(
|
||||||
|
|
@ -110,7 +115,12 @@ def _get_default_plans(portfolio_id: int) -> List[Plan]:
|
||||||
|
|
||||||
return [
|
return [
|
||||||
Plan.from_sqlalchemy(
|
Plan.from_sqlalchemy(
|
||||||
p, next(s for s in default_scenario_models if s.id == p.scenario_id)
|
p,
|
||||||
|
next(
|
||||||
|
Scenario.from_sqlalchemy(s)
|
||||||
|
for s in default_scenario_models
|
||||||
|
if s.id == p.scenario_id
|
||||||
|
),
|
||||||
)
|
)
|
||||||
for p in default_plan_models
|
for p in default_plan_models
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue