mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
update validation of PlanTriggerRequest to use cls rather than self
This commit is contained in:
parent
91eb9c68f1
commit
22a3e21f52
3 changed files with 8 additions and 10 deletions
|
|
@ -170,9 +170,7 @@ async def trigger_plan(body: PlanTriggerRequest):
|
||||||
p.get_components(cleaned, photo_supply_lookup, floor_area_decile_thresholds)
|
p.get_components(cleaned, photo_supply_lookup, floor_area_decile_thresholds)
|
||||||
|
|
||||||
recommender = Recommendations(property_instance=p, materials=materials)
|
recommender = Recommendations(property_instance=p, materials=materials)
|
||||||
# TODO: portfolio id as an input is temp
|
property_recommendations, property_representative_recommendations = recommender.recommend()
|
||||||
print("DELETE PORTFOLIO ID AS AN INPUT!!")
|
|
||||||
property_recommendations, property_representative_recommendations = recommender.recommend(body.portfolio_id)
|
|
||||||
|
|
||||||
if not property_recommendations:
|
if not property_recommendations:
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -31,21 +31,21 @@ class PlanTriggerRequest(BaseModel):
|
||||||
|
|
||||||
# Validator to ensure exclusions are within the pre-defined possibilities
|
# Validator to ensure exclusions are within the pre-defined possibilities
|
||||||
@validator('exclusions', each_item=True)
|
@validator('exclusions', each_item=True)
|
||||||
def check_exclusions(self, v):
|
def check_exclusions(cls, v):
|
||||||
if v not in self._allowed_exclusions:
|
if v not in cls._allowed_exclusions:
|
||||||
raise ValueError(f"{v} is not an allowed exclusion")
|
raise ValueError(f"{v} is not an allowed exclusion")
|
||||||
return v
|
return v
|
||||||
|
|
||||||
# Validator to ensure that the goal is within the pre-defined possibilities
|
# Validator to ensure that the goal is within the pre-defined possibilities
|
||||||
@validator('goal')
|
@validator('goal')
|
||||||
def check_goal(self, v):
|
def check_goal(cls, v):
|
||||||
if v not in self._allowed_goals:
|
if v not in cls._allowed_goals:
|
||||||
raise ValueError(f"{v} is not a valid goal")
|
raise ValueError(f"{v} is not a valid goal")
|
||||||
return v
|
return v
|
||||||
|
|
||||||
# Validator to ensure that the housing type is within the pre-defined possibilities
|
# Validator to ensure that the housing type is within the pre-defined possibilities
|
||||||
@validator('housing_type')
|
@validator('housing_type')
|
||||||
def check_housing_type(self, v):
|
def check_housing_type(cls, v):
|
||||||
if v not in self.allowed_housing_types:
|
if v not in cls._allowed_housing_types:
|
||||||
raise ValueError(f"{v} is not a valid housing type")
|
raise ValueError(f"{v} is not a valid housing type")
|
||||||
return v
|
return v
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class Recommendations:
|
||||||
self.heating_recommender = HeatingRecommender(property_instance=property_instance)
|
self.heating_recommender = HeatingRecommender(property_instance=property_instance)
|
||||||
self.hotwater_recommender = HotwaterRecommendations(property_instance=property_instance)
|
self.hotwater_recommender = HotwaterRecommendations(property_instance=property_instance)
|
||||||
|
|
||||||
def recommend(self, portfolio_id):
|
def recommend(self):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
This method runs the recommendations for the individual measures and then appends them to a list for output
|
This method runs the recommendations for the individual measures and then appends them to a list for output
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue