partial completion of results

This commit is contained in:
Guille Gutierrez 2023-07-31 16:55:39 -04:00
parent aeedbd370c
commit f0438e6776
2 changed files with 10 additions and 5 deletions

View File

@ -5,14 +5,14 @@ Copyright © 2023 Concordia CERC group
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
from properties import *
from hub_api.mockup.properties import *
class Building:
"""
Building class
"""
def __init__(self, building_info, catalog_archetype):
def __init__(self, building_info, result, catalog_archetype):
self._function = building_info.function
self._area = building_info.area
self._volume = building_info.volume
@ -21,8 +21,8 @@ class Building:
self._windows_area = building_info.windows_area
self._roof_area = building_info.roof_area
self._total_pv_area = building_info.total_pv_area
self._heating_consumption = building_info.heating_consumption
self._cooling_consumption = building_info.cooling_consumption
self._heating_consumption = heating_consumption
self._cooling_consumption = cooling_consumption
self._domestic_hot_water_consumption = building_info.domestic_hot_water_consumption
self._lighting_electrical_demand = building_info.lighting_electrical_demand
self._appliances_electrical_demand = building_info.appliances_electrical_demand

View File

@ -6,6 +6,7 @@ from flask_restful import Resource
from hub_api.config import Config
from hub_api.helpers.session_helper import session, refresh_session
from hub_api.mockup.building import Building
from costs.cost import Cost
class RetrofitResults(Resource, Config):
@ -32,6 +33,7 @@ class RetrofitResults(Resource, Config):
# retrieve the buildings info
buildings = []
buildings_info = []
mockups = {}
scenario_name = None
for scenario in payload['scenarios']:
@ -43,7 +45,7 @@ class RetrofitResults(Resource, Config):
building_info = self.database.building(building, user_id, application_id, scenario_name)
archetype = self.energy_systems_catalog.get_entry(building_info.system_name)
buildings_info.append(building_info)
buildings.append(Building(building_info, archetype))
mockups[building_info.name] = Building(building_info, archetype)
results = self.database.results(user_id, application_id, payload)
if results == {}:
@ -57,4 +59,7 @@ class RetrofitResults(Resource, Config):
key = next(iter(value))
values.append({key: json.loads(str(value[key]))})
building_results['insel meb'] = values
building_results['costs'] = Cost(mockups[building_results['name']], scenario_name=scenario)
return Response(json.dumps({'result': 'succeed', 'results': results}), status=200, headers=token)