diff --git a/hub_api/config.py b/hub_api/config.py index 95ad1da..6543edf 100644 --- a/hub_api/config.py +++ b/hub_api/config.py @@ -9,6 +9,7 @@ from pathlib import Path from hub.persistence.db_control import DBControl from hub.persistence.repository import Repository +from hub.catalog_factories.energy_systems_catalog_factory import EnergySystemsCatalogFactory class Config: @@ -23,6 +24,7 @@ class Config: self._database = DBControl(db_name=database_name, app_env=environment, dotenv_path=dotenv_path) self._repository = Repository(db_name=database_name, app_env=environment, dotenv_path=dotenv_path) + self._energy_systems_catalog = EnergySystemsCatalogFactory('montreal_custom').catalog @property def database(self): @@ -31,3 +33,7 @@ class Config: @property def repository(self): return self._repository + + @property + def energy_systems_catalog(self): + return self._energy_systems_catalog diff --git a/hub_api/persistence/retrofit_results.py b/hub_api/persistence/retrofit_results.py index d00bb47..dd2a935 100644 --- a/hub_api/persistence/retrofit_results.py +++ b/hub_api/persistence/retrofit_results.py @@ -31,15 +31,17 @@ class RetrofitResults(Resource, Config): # retrieve the buildings info buildings = [] buildings_info = [] + scenario_name = None + for scenario in payload['scenarios']: - key = next(iter(scenario)) - for name in scenario[key]: + scenario_name = next(iter(scenario)) + for name in scenario[scenario_name]: if name not in buildings: buildings.append(name) for building in buildings: - buildings_info.append(self.database.building_info(building, user_id, application_id, scenario)) - - print(buildings_info) + building_info = self.database.building(building, user_id, application_id, scenario_name) + self.energy_systems_catalog.get_entry(building_info.system_name) + buildings_info.append(building_info) results = self.database.results(user_id, application_id, payload) if results == {}: # no data found for the given parameters