Skip to content

Commit 2f289cb

Browse files
committed
used feed name and provider to filter out different DART
1 parent c1a8141 commit 2f289cb

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

api/src/shared/db_models/gtfs_rt_feed_impl.py

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,13 @@ def from_orm(cls, feed: Gtfsrealtimefeed | None, db_session: Session) -> GtfsRTF
2727
gtfs_rt_feed.locations = [LocationImpl.from_orm(item) for item in feed.locations] if feed.locations else []
2828
gtfs_rt_feed.entity_types = [item.name for item in feed.entitytypes] if feed.entitytypes else []
2929

30-
# Base query: same provider_id, but not the same feed
31-
query = (
32-
db_session.query(GtfsFeedOrm)
33-
.filter(
34-
GtfsFeedOrm.provider_id == feed.provider_id,
35-
GtfsFeedOrm.stable_id != feed.stable_id,
36-
)
37-
.options(joinedload(GtfsFeedOrm.locations))
30+
query = db_session.query(GtfsFeedOrm).filter(
31+
GtfsFeedOrm.provider == feed.provider,
32+
GtfsFeedOrm.feed_name == feed.feed_name,
33+
GtfsFeedOrm.stable_id != feed.stable_id,
3834
)
3935

40-
# If the GtfsRT feed has locations, require overlap
41-
rt_location_ids = {loc.id for loc in feed.locations} if feed.locations else set()
42-
feed_references = []
43-
for gtfs_feed in query.all():
44-
if rt_location_ids:
45-
gtfs_location_ids = {loc.id for loc in gtfs_feed.locations}
46-
if gtfs_location_ids.isdisjoint(rt_location_ids):
47-
continue
48-
49-
feed_references.append(gtfs_feed.stable_id)
50-
51-
gtfs_rt_feed.feed_references = feed_references
36+
gtfs_rt_feed.feed_references = [gtfs_feed.stable_id for gtfs_feed in query.all()]
5237

5338
return gtfs_rt_feed
5439

0 commit comments

Comments
 (0)