From 694717bd34a5e9aedaeca942abbf9905fcb81e2d Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Mon, 23 Feb 2026 14:14:07 +0000 Subject: [PATCH] addressing Dan's feedback --- recommendations/optimiser/optimiser_functions.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/recommendations/optimiser/optimiser_functions.py b/recommendations/optimiser/optimiser_functions.py index c17cdf1e..ab98113c 100644 --- a/recommendations/optimiser/optimiser_functions.py +++ b/recommendations/optimiser/optimiser_functions.py @@ -403,21 +403,25 @@ def flatten_recommendations_with_defaults(property_id, recommendations, selected def check_needs_ventilation( property_measure_types: Set[str], measures_needing_ventilation: List[str], - has_ventilation: bool, - ventilation_included: bool + property_already_has_ventilation: bool, + ventilation_in_included_measures: bool ) -> bool: """ Function to check if we need to include ventilation based on the measures selected and the property features :param property_measure_types: The set of measure types recommended for the property :param measures_needing_ventilation: The set of measure types that require ventilation - :param has_ventilation: Whether the property currently has ventilation - :param ventilation_included: Whether ventilation is already included in the recommended measures + :param property_already_has_ventilation: Whether the property currently has ventilation + :param ventilation_in_included_measures: Whether ventilation is already included in the recommended + measures :return: Boolean indicating whether ventilation needs to be included in the recommendations # TODO - none of the inputs of this function are well structured and so this is quite brittle - we should consider refactoring to make this more robust """ - return any( + + needs_ventilation = any( x in property_measure_types for x in measures_needing_ventilation - ) and not has_ventilation and ventilation_included + ) + + return needs_ventilation and not has_ventilation and ventilation_included