Partial correction in persistence

This commit is contained in:
Guille Gutierrez 2023-05-18 16:46:50 -04:00
parent 6e249073c5
commit 86d4d839b2

View File

@ -6,7 +6,6 @@ Project Coder Guille Gutierrez Guillermo.GutierrezMorote@concordia.ca
"""
import datetime
import logging
from typing import Union, Dict
from sqlalchemy import or_
from sqlalchemy import select
@ -109,7 +108,7 @@ class SimulationResults(Repository):
raise NotImplementedError('Missing either city_id or city_object_id')
except SQLAlchemyError as err:
logging.error('Error while deleting application: %s', err)
return None
raise SQLAlchemyError(err)
def _get_city(self, city_id) -> City:
"""
@ -135,7 +134,7 @@ class SimulationResults(Repository):
logging.error('Error while fetching city by city_id: %s', err)
SQLAlchemyError(err)
def get_simulation_results_by_city_id_city_object_id_and_names(self, city_id, city_object_id, result_names=None):
def get_simulation_results_by_city_id_city_object_id_and_names(self, city_id, city_object_id, result_names=None) -> [Model]:
"""
Fetch the simulation results based in the city_id or city_object_id with the given names or all
:param city_id: the city id
@ -151,11 +150,11 @@ class SimulationResults(Repository):
results = [r[0] for r in result_set]
if not result_names:
return results
_ = []
filtered_results = []
for result in results:
if result.name in result_names:
_.append(result)
return _
filtered_results.append(result)
return filtered_results
except SQLAlchemyError as err:
logging.error('Error while fetching city by city_id: %s', err)
return None