diff --git a/api/routes/online.py b/api/routes/online.py index 335f0ad..08f6551 100644 --- a/api/routes/online.py +++ b/api/routes/online.py @@ -37,16 +37,19 @@ def prepare_json(self, start_date=None, end_date=None): """Return all data""" session = session_creator() results = session.query(Online).all() + session.close() return [i.as_dict() for i in results] if start_date is not None and end_date is None: """Return all data since datetime""" session = session_creator() results = session.query(Online).filter(Online.date >= start_date) + session.close() return [i.as_dict() for i in results] if start_date is None and end_date is not None: """Return all data after datetime""" session = session_creator() results = session.query(Online).filter(Online.date <= end_date) + session.close() return [i.as_dict() for i in results] if start_date is not None and end_date is not None: """Return all data between two datetimes""" @@ -54,6 +57,7 @@ def prepare_json(self, start_date=None, end_date=None): results = session.query(Online).filter( Online.date <= end_date, Online.date >= start_date ) + session.close() return [i.as_dict() for i in results] def get(self): diff --git a/api/routes/text.py b/api/routes/text.py index 4c739fa..09fd66e 100644 --- a/api/routes/text.py +++ b/api/routes/text.py @@ -35,16 +35,19 @@ def prepare_json(self, start_date=None, end_date=None): if start_date is None and end_date is None: session = session_creator() results = session.query(Text).all() + session.close() return [i.as_dict() for i in results] if start_date is not None and end_date is None: """Return all data since datetime""" session = session_creator() results = session.query(Text).filter(Text.date >= start_date) + session.close() return [i.as_dict() for i in results] if start_date is None and end_date is not None: """Return all data after datetime""" session = session_creator() results = session.query(Text).filter(Text.date <= end_date) + session.close() return [i.as_dict() for i in results] if start_date is not None and end_date is not None: """Return all data between two datetimes""" @@ -52,6 +55,7 @@ def prepare_json(self, start_date=None, end_date=None): results = session.query(Text).filter( Text.date <= end_date, Text.date >= start_date ) + session.close() return [i.as_dict() for i in results] def get(self): diff --git a/api/routes/voice.py b/api/routes/voice.py index a405aec..8797e82 100644 --- a/api/routes/voice.py +++ b/api/routes/voice.py @@ -34,16 +34,19 @@ def prepare_json(self, start_date=None, end_date=None): if start_date is None and end_date is None: session = session_creator() results = session.query(Voice).all() + session.close() return [i.as_dict() for i in results] if start_date is not None and end_date is None: """Return all data since datetime""" session = session_creator() results = session.query(Voice).filter(Voice.date >= start_date) + session.close() return [i.as_dict() for i in results] if start_date is None and end_date is not None: """Return all data after datetime""" session = session_creator() results = session.query(Voice).filter(Voice.date <= end_date) + session.close() return [i.as_dict() for i in results] if start_date is not None and end_date is not None: """Return all data between two datetimes""" @@ -51,6 +54,7 @@ def prepare_json(self, start_date=None, end_date=None): results = session.query(Voice).filter( Voice.date <= end_date, Voice.date >= start_date ) + session.close() return [i.as_dict() for i in results] def get(self):