Skip to content

Commit ffd294c

Browse files
authored
fix: add reduce batch_size to 100 feeds (#1377)
1 parent 182e492 commit ffd294c

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

api/src/shared/common/db_utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from typing import Iterator, List, Dict, Optional
23

34
from geoalchemy2 import WKTElement
@@ -152,20 +153,18 @@ def get_geopolygons(db_session: Session, feeds: List[Feed], include_geometry: bo
152153
def get_all_gtfs_feeds(
153154
db_session: Session,
154155
published_only: bool = True,
155-
batch_size: int = 250,
156156
w_extracted_locations_only: bool = False,
157157
) -> Iterator[Gtfsfeed]:
158158
"""
159159
Fetch all GTFS feeds.
160160
161161
:param db_session: The database session.
162162
:param published_only: Include only the published feeds.
163-
:param batch_size: The number of feeds to fetch from the database at a time.
164-
A lower value means less memory but more queries.
165163
:param w_extracted_locations_only: Whether to include only feeds with extracted locations.
166164
167165
:return: The GTFS feeds in an iterator.
168166
"""
167+
batch_size = os.getenv("BATCH_SIZE", 100)
169168
batch_query = db_session.query(Gtfsfeed).order_by(Gtfsfeed.stable_id).yield_per(batch_size)
170169
if published_only:
171170
batch_query = batch_query.filter(Gtfsfeed.operational_status == "published")

0 commit comments

Comments
 (0)