Skip to content

Commit 7617ca7

Browse files
committed
fixed total_processed error
1 parent c1fa64c commit 7617ca7

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

functions-python/helpers/query_helper.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -175,35 +175,35 @@ def get_datasets_with_missing_reports_query(
175175
return query
176176

177177

178-
def get_feeds_ids_with_missing_bounding_boxes_query(
179-
db_session: Session,
180-
) -> Query:
181-
"""
182-
Get GTFS feeds ids where the dataset is missing a bounding box.
183-
184-
Args:
185-
db_session: SQLAlchemy session
186-
187-
Returns:
188-
A SQLAlchemy query object for GTFS feeds with datasets missing bounding boxes
189-
ordered by dataset and feed stable id.
190-
"""
191-
query = (
192-
db_session.query(
193-
Gtfsfeed.stable_id,
194-
Gtfsdataset.stable_id,
195-
)
196-
.select_from(Gtfsfeed)
197-
.join(Gtfsdataset, Gtfsdataset.feed_id == Gtfsfeed.id)
198-
.filter(Gtfsdataset.bounding_box.is_(None))
199-
.filter(
200-
~Gtfsfeed.feedlocationgrouppoints.any()
201-
) # Only feeds with no location group points
202-
.distinct(Gtfsfeed.stable_id, Gtfsdataset.stable_id)
203-
.order_by(Gtfsdataset.stable_id, Gtfsfeed.stable_id)
204-
)
205-
206-
return query
178+
# def get_feeds_ids_with_missing_bounding_boxes_query(
179+
# db_session: Session,
180+
# ) -> Query:
181+
# """
182+
# Get GTFS feeds ids where the dataset is missing a bounding box.
183+
184+
# Args:
185+
# db_session: SQLAlchemy session
186+
187+
# Returns:
188+
# A SQLAlchemy query object for GTFS feeds with datasets missing bounding boxes
189+
# ordered by dataset and feed stable id.
190+
# """
191+
# query = (
192+
# db_session.query(
193+
# Gtfsfeed.stable_id,
194+
# Gtfsdataset.stable_id,
195+
# )
196+
# .select_from(Gtfsfeed)
197+
# .join(Gtfsdataset, Gtfsdataset.feed_id == Gtfsfeed.id)
198+
# .filter(Gtfsdataset.bounding_box.is_(None))
199+
# .filter(
200+
# ~Gtfsfeed.feedlocationgrouppoints.any()
201+
# ) # Only feeds with no location group points
202+
# .distinct(Gtfsfeed.stable_id, Gtfsdataset.stable_id)
203+
# .order_by(Gtfsdataset.stable_id, Gtfsfeed.stable_id)
204+
# )
205+
206+
# return query
207207

208208

209209
def get_feeds_with_missing_bounding_boxes_query(

functions-python/tasks_executor/src/tasks/missing_bounding_boxes/rebuild_missing_bounding_boxes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from shared.database.database import with_db_session
77
from shared.helpers.pub_sub import publish_messages
88
from shared.helpers.query_helper import (
9-
get_feeds_ids_with_missing_bounding_boxes_query,
109
get_feeds_with_missing_bounding_boxes_query,
1110
)
1211
from shared.database_gen.sqlacodegen_models import Gtfsdataset
@@ -47,7 +46,7 @@ def rebuild_missing_bounding_boxes(
4746
logging.warning(
4847
"Invalid after_date format, expected ISO format (YYYY-MM-DD)"
4948
)
50-
query = get_feeds_ids_with_missing_bounding_boxes_query(db_session)
49+
query = get_feeds_with_missing_bounding_boxes_query(db_session)
5150
if filter_after:
5251
query = query.filter(Gtfsdataset.downloaded_at >= filter_after)
5352
feeds = query.all()
@@ -70,9 +69,10 @@ def rebuild_missing_bounding_boxes(
7069
project_id = os.getenv("PROJECT_ID")
7170

7271
logging.info("Publishing to topic: %s", pubsub_topic_name)
73-
publish_messages(prepare_feeds_data(db_session), project_id, pubsub_topic_name)
72+
feeds_data = prepare_feeds_data(db_session)
73+
publish_messages(feeds_data, project_id, pubsub_topic_name)
7474

75-
total_processed = len(feeds)
75+
total_processed = len(feeds_data)
7676
logging.info(
7777
"Published %s feeds with missing bounding boxes to Pub/Sub topic: %s, filtered after %s.",
7878
total_processed,

0 commit comments

Comments
 (0)