From bdf11e9c36415cef88d80d8d7bc86a0ef4deba61 Mon Sep 17 00:00:00 2001 From: Giacomo Sarrocco Date: Wed, 27 Sep 2023 20:28:15 +0200 Subject: [PATCH] Make limit on get_stop_times method optional --- MuoVErsi/sources/GTFS/source.py | 5 +++-- MuoVErsi/sources/base.py | 2 +- MuoVErsi/sources/trenitalia.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/MuoVErsi/sources/GTFS/source.py b/MuoVErsi/sources/GTFS/source.py index 2d46f60..fa564be 100644 --- a/MuoVErsi/sources/GTFS/source.py +++ b/MuoVErsi/sources/GTFS/source.py @@ -173,7 +173,7 @@ def upload_stops_clusters_to_db(self, force=False) -> bool: return True def get_stop_times(self, stop: Station, line, start_time, day, - offset_times, count=False): + offset_times, count=False, limit=True): cur = self.con.cursor() route_name, route_id = line.split('-') if '-' in line else (line, '') @@ -261,7 +261,8 @@ def get_stop_times(self, stop: Station, line, start_time, day, params += (line,) if not count: - params += (self.LIMIT, offset_times) + limit = self.LIMIT if limit else 100000 + params += (limit, offset_times) results = cur.execute(query, params).fetchall() diff --git a/MuoVErsi/sources/base.py b/MuoVErsi/sources/base.py index b6c7ba9..0d03cdf 100644 --- a/MuoVErsi/sources/base.py +++ b/MuoVErsi/sources/base.py @@ -221,7 +221,7 @@ def search_stops(self, name=None, lat=None, lon=None, page=1, limit=4, all_sourc return stations, found def get_stop_times(self, stop: Station, line, start_time, day, - offset_times, count=False): + offset_times, count=False, limit=True): raise NotImplementedError def get_stop_times_between_stops(self, dep_stop: Station, arr_stop: Station, line, start_time, diff --git a/MuoVErsi/sources/trenitalia.py b/MuoVErsi/sources/trenitalia.py index 9204827..8b93812 100644 --- a/MuoVErsi/sources/trenitalia.py +++ b/MuoVErsi/sources/trenitalia.py @@ -138,7 +138,7 @@ def file_path(self): return os.path.join(parent_dir, 'trenitalia.db') def get_stop_times(self, stop: Station, line, start_time, day, - offset_times, count=False): + offset_times, count=False, limit=True): day_start = datetime.combine(day, time(0)) if start_time == '':