This commit is contained in:
Guille Gutierrez 2024-04-18 07:32:32 +02:00
parent 0623faaafc
commit 8cfd6ebe82
2 changed files with 1 additions and 6 deletions

View File

@ -10,7 +10,6 @@ from hub.helpers.dictionaries import Dictionaries
from hub_api.mockup.properties import * from hub_api.mockup.properties import *
import pandas as pd
class Building: class Building:
@ -214,14 +213,13 @@ class Building:
:return: [EnergySystem] :return: [EnergySystem]
""" """
_energy_systems = [] _energy_systems = []
for system in self._catalog_archetype.systems: for system in self._catalog_archetype.systems:
_hub_demand_types = [] _hub_demand_types = []
for demand_type in system.demand_types: for demand_type in system.demand_types:
# todo: generalize this when we have more catalogs # todo: generalize this when we have more catalogs
_hub_demand_types.append(Dictionaries().montreal_demand_type_to_hub_energy_demand_type[demand_type]) _hub_demand_types.append(Dictionaries().montreal_demand_type_to_hub_energy_demand_type[demand_type])
demands = _hub_demand_types demands = _hub_demand_types
fuel_type = Dictionaries().montreal_custom_fuel_to_hub_fuel[system.generation_system.fuel_type] fuel_type = Dictionaries().montreal_custom_fuel_to_hub_fuel[system.generation_systems[0].fuel_type]
generic_generation_system = GenericGenerationSystem() generic_generation_system = GenericGenerationSystem()
generic_generation_system.fuel_type = fuel_type generic_generation_system.fuel_type = fuel_type
generation_system = GenerationSystem() generation_system = GenerationSystem()

View File

@ -97,9 +97,7 @@ class RetrofitResults(Resource, Config):
payload = request.get_json() payload = request.get_json()
if 'scenarios' not in payload: if 'scenarios' not in payload:
return Response(json.dumps({'error': 'Bad request'}), status=400, headers=token) return Response(json.dumps({'error': 'Bad request'}), status=400, headers=token)
start = datetime.datetime.now()
results = self.database.results(user_id, application_id, payload) results = self.database.results(user_id, application_id, payload)
print(f'{datetime.datetime.now()- start}')
if results == {}: if results == {}:
# no data found for the given parameters # no data found for the given parameters
return Response(json.dumps({'result': 'succeed', 'results': results}), status=200, headers=token) return Response(json.dumps({'result': 'succeed', 'results': results}), status=200, headers=token)
@ -117,5 +115,4 @@ class RetrofitResults(Resource, Config):
f.start() f.start()
for f in t: for f in t:
f.join() f.join()
print(f'retrieve calculations {datetime.datetime.now() - start}')
return Response(json.dumps({'result': 'succeed', 'results': results}), status=200, headers=token) return Response(json.dumps({'result': 'succeed', 'results': results}), status=200, headers=token)