Partial completion for costs and co2 emitions

This commit is contained in:
Guille Gutierrez 2023-07-31 14:31:50 -04:00
parent 1a38c83dee
commit c30bf275c5
2 changed files with 13 additions and 5 deletions

View File

@ -9,6 +9,7 @@ from pathlib import Path
from hub.persistence.db_control import DBControl from hub.persistence.db_control import DBControl
from hub.persistence.repository import Repository from hub.persistence.repository import Repository
from hub.catalog_factories.energy_systems_catalog_factory import EnergySystemsCatalogFactory
class Config: class Config:
@ -23,6 +24,7 @@ class Config:
self._database = DBControl(db_name=database_name, app_env=environment, dotenv_path=dotenv_path) 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._repository = Repository(db_name=database_name, app_env=environment, dotenv_path=dotenv_path)
self._energy_systems_catalog = EnergySystemsCatalogFactory('montreal_custom').catalog
@property @property
def database(self): def database(self):
@ -31,3 +33,7 @@ class Config:
@property @property
def repository(self): def repository(self):
return self._repository return self._repository
@property
def energy_systems_catalog(self):
return self._energy_systems_catalog

View File

@ -31,15 +31,17 @@ class RetrofitResults(Resource, Config):
# retrieve the buildings info # retrieve the buildings info
buildings = [] buildings = []
buildings_info = [] buildings_info = []
scenario_name = None
for scenario in payload['scenarios']: for scenario in payload['scenarios']:
key = next(iter(scenario)) scenario_name = next(iter(scenario))
for name in scenario[key]: for name in scenario[scenario_name]:
if name not in buildings: if name not in buildings:
buildings.append(name) buildings.append(name)
for building in buildings: for building in buildings:
buildings_info.append(self.database.building_info(building, user_id, application_id, scenario)) building_info = self.database.building(building, user_id, application_id, scenario_name)
self.energy_systems_catalog.get_entry(building_info.system_name)
print(buildings_info) buildings_info.append(building_info)
results = self.database.results(user_id, application_id, payload) results = self.database.results(user_id, application_id, payload)
if results == {}: if results == {}:
# no data found for the given parameters # no data found for the given parameters