diff --git a/backend/categorisation/categorisation_trigger_request.py b/backend/categorisation/categorisation_trigger_request.py index fbc2328b..44ac0ff1 100644 --- a/backend/categorisation/categorisation_trigger_request.py +++ b/backend/categorisation/categorisation_trigger_request.py @@ -9,4 +9,4 @@ class CategorisationTriggerRequest(BaseModel): scenario_priority_order: Optional[List[int]] = None -# {"portfolio_id": 556, "plans_to_consider": [1589319,1589320], "plan_priority_order": [1589319,1589320]} +# {"portfolio_id": 556, "scenarios_to_consider": [1039,1041], "scenario_priority_order": [1041,1039]} diff --git a/backend/categorisation/local_handler/invoke_local_lambda.py b/backend/categorisation/local_handler/invoke_local_lambda.py index 127d2575..1446a1e3 100644 --- a/backend/categorisation/local_handler/invoke_local_lambda.py +++ b/backend/categorisation/local_handler/invoke_local_lambda.py @@ -9,9 +9,9 @@ payload = { { "body": json.dumps( { - "portfolio_id": 556, - "scenarios_to_consider": [1039, 1041], - "scenarios_priority_order": [], + "portfolio_id": 569, + "scenarios_to_consider": [1069, 1060], + "scenario_priority_order": [1069, 1060], } ) } diff --git a/backend/categorisation/local_runner.py b/backend/categorisation/local_runner.py index 599cbbbb..f4718ffc 100644 --- a/backend/categorisation/local_runner.py +++ b/backend/categorisation/local_runner.py @@ -2,9 +2,11 @@ from backend.categorisation.processor import process_portfolio def main() -> None: - portfolio_id = 556 + portfolio_id = 569 + scenarios_to_consider = [1069, 1060] + scenario_priority_order = [1069, 1060] - process_portfolio(portfolio_id) + process_portfolio(portfolio_id, scenarios_to_consider, scenario_priority_order) if __name__ == "__main__": diff --git a/backend/categorisation/processor.py b/backend/categorisation/processor.py index 966ecbf5..5ed75d8f 100644 --- a/backend/categorisation/processor.py +++ b/backend/categorisation/processor.py @@ -37,8 +37,10 @@ def process_portfolio( ) plans: List[Plan] = _load_plans_for_portfolio(portfolio_id, scenarios_to_consider) + logger.info(f"Successfully loaded {len(plans)}") plans_by_property: Dict[int, List[Plan]] = _group_plans_by_property(plans) + logger.info("Successfully grouped plans by property") updated_plan_models: List[PlanModel] = [] updated_scenario_models: List[ScenarioModel] = [] @@ -51,6 +53,7 @@ def process_portfolio( cheapest_plan = choose_cheapest_relevant_plan( property_plans, scenario_priority_order ) + logger.info(f"Successfully found cheapest plan for Property {property_id}") updated_property_plan_models, updated_property_scenario_models = ( _update_plan_and_scenario_objects(property_plans, cheapest_plan) @@ -60,6 +63,7 @@ def process_portfolio( updated_scenario_models.extend(updated_property_scenario_models) if len(updated_plan_models) > 0: + logger.info(f"Updating {len(updated_plan_models)} Plans in database") bulk_update_plans(updated_plan_models, updated_scenario_models) logger.info("Successfully updated Plan default values in database") @@ -116,9 +120,10 @@ def _unset_defaults_for_scenarios_not_being_considered( if id not in scenarios_to_consider: scenarios_to_unset_default.append(id) - logger.info( - f"Unsetting {scenarios_to_unset_default} as default scenario(s) as not included in provided list of scenarios to consider" - ) + if len(scenarios_to_unset_default) > 0: + logger.info( + f"Unsetting {scenarios_to_unset_default} as default scenario(s) as not included in provided list of scenarios to consider" + ) if len(scenarios_to_unset_default) > 0: plans_to_unset_default: List[int] = get_plan_ids_by_scenario_ids( @@ -133,9 +138,9 @@ def _load_plans_for_portfolio( ) -> List[Plan]: if scenarios_to_consider: - logger.info(f"Getting {len(scenarios_to_consider)} plans") + logger.info(f"Getting plans for {len(scenarios_to_consider)} scenarios") plan_models: List[PlanModel] = get_plans_by_scenario_ids(scenarios_to_consider) - + logger.info(f"Got {len(plan_models)} plan models from database") else: logger.info( f"No list of Plans to consider provided. Getting all Plans for portfolio {portfolio_id}" @@ -159,11 +164,8 @@ def _load_plans_for_portfolio( plans.append( Plan.from_sqlalchemy(model, Scenario.from_sqlalchemy(scenario_model)) ) - logger.debug( - f"Successfully mapped plan {model.id} and scenario {scenario_model.id} to domain object" - ) - logger.debug(f"Got {len(plans)} plans from database") + logger.info(f"Got {len(plans)} Plans") return plans