added condition check for solar

This commit is contained in:
Khalim Conn-Kowlessar 2024-06-04 11:23:54 +01:00
parent a5876d40db
commit bbe35400bd
3 changed files with 18 additions and 12 deletions

View file

@ -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

View file

@ -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 = []

View file

@ -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