mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
tidy up imports
This commit is contained in:
parent
3d72d967ec
commit
caeab2bf82
1 changed files with 12 additions and 18 deletions
|
|
@ -6,21 +6,16 @@ from tqdm import tqdm
|
|||
import pandas as pd
|
||||
import numpy as np
|
||||
|
||||
from etl.epc.Record import EPCRecord
|
||||
from backend.Funding import Funding
|
||||
from backend.SearchEpc import SearchEpc
|
||||
|
||||
from etl.epc.Record import EPCRecord
|
||||
from sqlalchemy.exc import IntegrityError, OperationalError
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from starlette.responses import Response
|
||||
|
||||
from backend.app.config import get_settings, get_prediction_buckets
|
||||
from backend.app.db.connection import db_engine
|
||||
from backend.app.db.functions.property_functions import (
|
||||
create_property_details_epc, create_property_targets, update_property_data,
|
||||
update_or_create_property_spatial_details, ensure_property_exists
|
||||
)
|
||||
from backend.app.db.functions.recommendations_functions import (
|
||||
create_plan, upload_recommendations, create_scenario
|
||||
)
|
||||
import backend.app.db.functions as db_funcs
|
||||
|
||||
from backend.app.db.models.portfolio import rating_lookup
|
||||
|
|
@ -45,7 +40,6 @@ from etl.bill_savings.KwhData import KwhData
|
|||
from etl.spatial.OpenUprnClient import OpenUprnClient
|
||||
from etl.find_my_epc.RetrieveFindMyEpc import RetrieveFindMyEpc
|
||||
|
||||
from backend.Funding import Funding
|
||||
from recommendations.optimiser.funding_optimiser import optimise_with_funding_paths
|
||||
from recommendations.recommendation_utils import convert_thickness_to_numeric, get_wall_u_value
|
||||
|
||||
|
|
@ -573,7 +567,7 @@ async def model_engine(body: PlanTriggerRequest):
|
|||
session, uprn if uprn is not None else epc_searcher.uprn
|
||||
)
|
||||
|
||||
property_id, is_new = ensure_property_exists(
|
||||
property_id, is_new = db_funcs.property_functions.ensure_property_exists(
|
||||
session, body, epc_searcher, energy_assessment, landlord_property_id=config.get("landlord_property_id")
|
||||
)
|
||||
if not property_id:
|
||||
|
|
@ -589,7 +583,7 @@ async def model_engine(body: PlanTriggerRequest):
|
|||
)
|
||||
|
||||
if is_new:
|
||||
create_property_targets(
|
||||
db_funcs.property_functions.create_property_targets(
|
||||
session,
|
||||
property_id=property_id,
|
||||
portfolio_id=body.portfolio_id,
|
||||
|
|
@ -1134,7 +1128,7 @@ async def model_engine(body: PlanTriggerRequest):
|
|||
# We don't need to create a new scenario, we just use the existing one
|
||||
scenario_id = body.scenario_id
|
||||
else:
|
||||
engine_scenario = create_scenario(
|
||||
engine_scenario = db_funcs.recommendations_functions.create_scenario(
|
||||
session=session,
|
||||
scenario={
|
||||
"name": body.scenario_name,
|
||||
|
|
@ -1183,20 +1177,20 @@ async def model_engine(body: PlanTriggerRequest):
|
|||
property_details_epc = p.get_property_details_epc(
|
||||
portfolio_id=body.portfolio_id, rating_lookup=rating_lookup,
|
||||
)
|
||||
create_property_details_epc(session, property_details_epc)
|
||||
db_funcs.property_functions.create_property_details_epc(session, property_details_epc)
|
||||
|
||||
update_or_create_property_spatial_details(session, p.uprn, p.spatial)
|
||||
db_funcs.property_functions.update_or_create_property_spatial_details(session, p.uprn,
|
||||
p.spatial)
|
||||
|
||||
property_data = p.get_full_property_data(current_valuation=valuations["current_value"])
|
||||
|
||||
update_property_data(
|
||||
db_funcs.property_functions.update_property_data(
|
||||
session, property_id=p.id, portfolio_id=body.portfolio_id, property_data=property_data
|
||||
)
|
||||
|
||||
if not recommendations_to_upload:
|
||||
continue
|
||||
|
||||
new_plan_id = create_plan(session, {
|
||||
new_plan_id = db_funcs.recommendations_functions.create_plan(session, {
|
||||
"portfolio_id": body.portfolio_id,
|
||||
"property_id": p.id,
|
||||
"scenario_id": scenario_id,
|
||||
|
|
@ -1214,7 +1208,7 @@ async def model_engine(body: PlanTriggerRequest):
|
|||
"plan_type": eco_packages.get(p.id, (None, None, None))[2]
|
||||
})
|
||||
|
||||
upload_recommendations(
|
||||
db_funcs.recommendations_functions.upload_recommendations(
|
||||
session, recommendations_to_upload, p.id, new_plan_id
|
||||
)
|
||||
db_funcs.funding_functions.upload_funding(session, p, new_plan_id, recommendations_to_upload)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue