diff --git a/backend/app/plan/router.py b/backend/app/plan/router.py index 6ee9dfe2..fdbee9b7 100644 --- a/backend/app/plan/router.py +++ b/backend/app/plan/router.py @@ -751,8 +751,7 @@ async def build_mds(body: MdsRequest): mds_recommendations, property_representative_recommendations, errors = mds.build() if any([len(x) for x in errors.values()]): - blah - logger.info("Errors occurred during MDS build") + raise Exception("Errors occurred during MDS build") recommendations[p.id] = mds_recommendations representative_recommendations[p.id] = property_representative_recommendations diff --git a/recommendations/Mds.py b/recommendations/Mds.py index ad3c4d2e..02ed3d06 100644 --- a/recommendations/Mds.py +++ b/recommendations/Mds.py @@ -174,6 +174,10 @@ class Mds: pruned_measures.append(measure) continue + if measure == "solar_pv": + if self.solar_recommender.is_solar_pv_valid(): + pruned_measures.append(measure) + raise NotImplementedError("Implement me") pruned_measures_formatted = [] diff --git a/recommendations/SolarPvRecommendations.py b/recommendations/SolarPvRecommendations.py index 14161da3..a9255370 100644 --- a/recommendations/SolarPvRecommendations.py +++ b/recommendations/SolarPvRecommendations.py @@ -75,15 +75,7 @@ class SolarPvRecommendations: } ] - def recommend(self, phase): - """ - We check if a property is potentially suitable for solar PV based on the following criteria: - - The property is a house or bungalow - - The property has a flat or pitched roof - - The property does not have existing solar pv - :return: - """ - + def is_solar_pv_valid(self): is_valid_property_type = self.property.data["property-type"] in ["House", "Bungalow", "Maisonette"] is_valid_roof_type = ( self.property.roof["is_flat"] or self.property.roof["is_pitched"] or self.property.roof["is_roof_room"] @@ -93,7 +85,18 @@ class SolarPvRecommendations: None, 0, self.property.DATA_ANOMALY_MATCHES ] - if not is_valid_property_type or not is_valid_roof_type or not has_no_existing_solar_pv: + return is_valid_property_type and is_valid_roof_type and has_no_existing_solar_pv + + def recommend(self, phase): + """ + We check if a property is potentially suitable for solar PV based on the following criteria: + - The property is a house or bungalow + - The property has a flat or pitched roof + - The property does not have existing solar pv + :return: + """ + + if not self.is_solar_pv_valid(): return solar_pv_percentage = self.property.solar_pv_percentage