mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
adding scoring data
This commit is contained in:
parent
340e8118eb
commit
f9e9cb59a6
2 changed files with 40 additions and 4 deletions
|
|
@ -230,6 +230,29 @@ class Property:
|
|||
|
||||
# self.base_difference_record.df
|
||||
|
||||
def simulate_all_representative_recommendations(
|
||||
self, property_representative_recommendations,
|
||||
):
|
||||
"""
|
||||
This method was put together to simulate the impact of the representative recommendations on the property
|
||||
all at once, for usage within the mds report
|
||||
:return:
|
||||
"""
|
||||
|
||||
recommendation_record = self.base_difference_record.df.to_dict("records")[
|
||||
0
|
||||
].copy()
|
||||
|
||||
scoring_dict = self.create_recommendation_scoring_data(
|
||||
property_id=self.id,
|
||||
recommendation_record=recommendation_record,
|
||||
recommendations=property_representative_recommendations,
|
||||
primary_recommendation_id=self.id,
|
||||
non_invasive_recommendations=self.non_invasive_recommendations,
|
||||
)
|
||||
|
||||
return scoring_dict
|
||||
|
||||
def adjust_difference_record_with_recommendations(
|
||||
self, property_recommendations, property_representative_recommendations
|
||||
):
|
||||
|
|
|
|||
|
|
@ -641,9 +641,14 @@ async def build_mds(body: PlanTriggerRequest):
|
|||
input_properties = []
|
||||
for property_id, config in tqdm(enumerate(plan_input), total=len(plan_input)):
|
||||
# We validate each record in the file. If the record is NOT valid, we need to handle this accordingly
|
||||
uprn = config.get("uprn", None)
|
||||
if uprn:
|
||||
uprn = int(float(uprn))
|
||||
|
||||
if config["address"] in ["Flat Over 20 Holborough Road", "Flat above 7 Malling Road"]:
|
||||
print("TEMP - not using uprn")
|
||||
uprn = None
|
||||
else:
|
||||
uprn = config.get("uprn", None)
|
||||
if uprn:
|
||||
uprn = int(float(uprn))
|
||||
|
||||
epc_searcher = SearchEpc(
|
||||
address1=config["address"],
|
||||
|
|
@ -728,7 +733,6 @@ async def build_mds(body: PlanTriggerRequest):
|
|||
p.get_spatial_data(uprn_filenames)
|
||||
|
||||
logger.info("Getting components and epc recommendations")
|
||||
recommendations = {}
|
||||
recommendations_scoring_data = []
|
||||
representative_recommendations = {}
|
||||
|
||||
|
|
@ -741,6 +745,15 @@ async def build_mds(body: PlanTriggerRequest):
|
|||
if errors:
|
||||
logger.info("Errors occurred during MDS build")
|
||||
|
||||
representative_recommendations[p.id] = property_representative_recommendations
|
||||
|
||||
# Build the scoring data
|
||||
p.create_base_difference_epc_record(cleaned_lookup=cleaned)
|
||||
p.simulate_all_representative_recommendations(property_representative_recommendations)
|
||||
|
||||
recommendations_scoring_data.extend(p.recommendations_scoring_data)
|
||||
|
||||
|
||||
|
||||
except IntegrityError:
|
||||
logger.error("Database integrity error occurred", exc_info=True)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue