Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions api/src/feeds/impl/datasets_api_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from shared.common.error_handling import (
dataset_not_found,
)
from feeds.impl.models.gtfs_dataset_impl import GtfsDatasetImpl
from shared.db_models.gtfs_dataset_impl import GtfsDatasetImpl
from feeds_gen.apis.datasets_api_base import BaseDatasetsApi
from feeds_gen.models.gtfs_dataset import GtfsDataset

Expand Down Expand Up @@ -50,7 +50,8 @@ def get_datasets_gtfs(query: Query, session: Session, limit: int = None, offset:
offset=offset,
group_by=lambda x: x[0].stable_id,
)

if not dataset_groups:
return []
gtfs_datasets = []
for dataset_group in dataset_groups:
dataset_objects: Tuple[Gtfsdataset, ...]
Expand Down
12 changes: 6 additions & 6 deletions api/src/feeds/impl/feeds_api_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

from feeds.impl.datasets_api_impl import DatasetsApiImpl
from feeds.impl.error_handling import raise_http_error, raise_http_validation_error, convert_exception
from feeds.impl.models.entity_type_enum import EntityType
from feeds.impl.models.feed_impl import FeedImpl
from feeds.impl.models.gbfs_feed_impl import GbfsFeedImpl
from feeds.impl.models.gtfs_feed_impl import GtfsFeedImpl
from feeds.impl.models.gtfs_rt_feed_impl import GtfsRTFeedImpl
from shared.db_models.entity_type_enum import EntityType
from shared.db_models.feed_impl import FeedImpl
from shared.db_models.gbfs_feed_impl import GbfsFeedImpl
from shared.db_models.gtfs_feed_impl import GtfsFeedImpl
from shared.db_models.gtfs_rt_feed_impl import GtfsRTFeedImpl
from feeds_gen.apis.feeds_api_base import BaseFeedsApi
from feeds_gen.models.feed import Feed
from feeds_gen.models.gbfs_feed import GbfsFeed
Expand Down Expand Up @@ -183,7 +183,7 @@ def get_gtfs_feed_datasets(
).filter(DatasetsApiImpl.create_dataset_query().filter(FeedOrm.stable_id == gtfs_feed_id))

if latest:
query = query.join(Gtfsdataset.feed).filter(Gtfsdataset.id == FeedOrm.latest_dataset_id)
query = query.join(Gtfsfeed, Gtfsfeed.latest_dataset_id == Gtfsdataset.id)
Copy link
Copy Markdown
Member Author

@davidgamez davidgamez Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the latest dataset filter fix


return DatasetsApiImpl.get_datasets_gtfs(query, session=db_session, limit=limit, offset=offset)

Expand Down
2 changes: 1 addition & 1 deletion api/src/feeds/impl/search_api_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from shared.database.database import Database, with_db_session
from shared.database.sql_functions.unaccent import unaccent
from shared.database_gen.sqlacodegen_models import t_feedsearch
from feeds.impl.models.search_feed_item_result_impl import SearchFeedItemResultImpl
from shared.db_models.search_feed_item_result_impl import SearchFeedItemResultImpl
from feeds_gen.apis.search_api_base import BaseSearchApi
from feeds_gen.models.search_feeds200_response import SearchFeeds200Response
from middleware.request_context import is_user_email_restricted
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from shared.database_gen.sqlacodegen_models import Feed
from feeds.impl.models.external_id_impl import ExternalIdImpl
from feeds.impl.models.redirect_impl import RedirectImpl
from shared.db_models.external_id_impl import ExternalIdImpl
from shared.db_models.redirect_impl import RedirectImpl
from feeds_gen.models.basic_feed import BasicFeed
from feeds_gen.models.source_info import SourceInfo

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from feeds.impl.models.basic_feed_impl import BaseFeedImpl
from shared.db_models.basic_feed_impl import BaseFeedImpl
from feeds_gen.models.feed import Feed
from shared.database_gen.sqlacodegen_models import Feed as FeedOrm

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from feeds.impl.models.bounding_box_impl import BoundingBoxImpl
from feeds.impl.models.feed_impl import FeedImpl
from feeds.impl.models.gbfs_version_impl import GbfsVersionImpl
from shared.db_models.bounding_box_impl import BoundingBoxImpl
from shared.db_models.feed_impl import FeedImpl
from shared.db_models.gbfs_version_impl import GbfsVersionImpl
from shared.database_gen.sqlacodegen_models import Gbfsfeed as GbfsFeedOrm
from feeds.impl.models.location_impl import LocationImpl
from shared.db_models.location_impl import LocationImpl
from feeds_gen.models.gbfs_feed import GbfsFeed


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from feeds.impl.models.gbfs_endpoint_impl import GbfsEndpointImpl
from feeds.impl.models.gbfs_validation_report_impl import GbfsValidationReportImpl
from shared.db_models.gbfs_endpoint_impl import GbfsEndpointImpl
from shared.db_models.gbfs_validation_report_impl import GbfsValidationReportImpl
from feeds_gen.models.gbfs_version import GbfsVersion
from shared.database_gen.sqlacodegen_models import Gbfsversion as GbfsVersionOrm

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from typing import List

from shared.database_gen.sqlacodegen_models import Gtfsdataset, Validationreport
from feeds.impl.models.bounding_box_impl import BoundingBoxImpl
from feeds.impl.models.validation_report_impl import ValidationReportImpl
from shared.db_models.bounding_box_impl import BoundingBoxImpl
from shared.db_models.validation_report_impl import ValidationReportImpl
from feeds_gen.models.gtfs_dataset import GtfsDataset
from utils.model_utils import compare_java_versions

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from feeds.impl.models.bounding_box_impl import BoundingBoxImpl
from feeds.impl.models.feed_impl import FeedImpl
from shared.db_models.bounding_box_impl import BoundingBoxImpl
from shared.db_models.feed_impl import FeedImpl
from shared.database_gen.sqlacodegen_models import Gtfsfeed as GtfsfeedOrm
from feeds.impl.models.latest_dataset_impl import LatestDatasetImpl
from feeds.impl.models.location_impl import LocationImpl
from shared.db_models.latest_dataset_impl import LatestDatasetImpl
from shared.db_models.location_impl import LocationImpl
from feeds_gen.models.gtfs_feed import GtfsFeed


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from feeds.impl.models.feed_impl import FeedImpl
from shared.db_models.feed_impl import FeedImpl
from shared.database_gen.sqlacodegen_models import Gtfsrealtimefeed as GtfsRTFeedOrm
from feeds.impl.models.location_impl import LocationImpl
from shared.db_models.location_impl import LocationImpl
from feeds_gen.models.gtfs_rt_feed import GtfsRTFeed


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from functools import reduce

from shared.database_gen.sqlacodegen_models import Gtfsdataset
from feeds.impl.models.bounding_box_impl import BoundingBoxImpl
from shared.db_models.bounding_box_impl import BoundingBoxImpl
from feeds_gen.models.latest_dataset import LatestDataset
from feeds_gen.models.latest_dataset_validation_report import LatestDatasetValidationReport
from utils.model_utils import compare_java_versions
Expand Down
22 changes: 22 additions & 0 deletions api/tests/integration/test_datasets_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,28 @@ def test_feeds_gtfs_id_datasets_get(client: TestClient):
assert response.status_code == 200


def test_feeds_gtfs_datasets_latest_get(client: TestClient):
"""Test case for feeds_gtfs_id_datasets_get"""
params = [
("latest", True),
("limit", 10),
("offset", 0),
("filter", "status=active"),
("sort", "+provider"),
]
response = client.request(
"GET",
"/v1/gtfs_feeds/{id}/datasets".format(id=TEST_GTFS_FEED_STABLE_IDS[0]),
headers=authHeaders,
params=params,
)

assert response.status_code == 200
json_response = response.json()
assert len(json_response) == 1, "Expected only the latest datasets"
assert json_response[0]["id"] == TEST_DATASET_STABLE_IDS[1] # dataset-2


def test_feeds_wrong_gtfs_id_datasets_get(client: TestClient):
"""Test case for feeds_gtfs_id_datasets_get where the gtfs feed id does not exist"""

Expand Down
6 changes: 3 additions & 3 deletions api/tests/unittest/models/test_basic_feed_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from datetime import datetime
from zoneinfo import ZoneInfo

from feeds.impl.models.feed_impl import FeedImpl
from shared.db_models.feed_impl import FeedImpl
from shared.database_gen.sqlacodegen_models import (
Feed,
Externalid,
Expand All @@ -13,8 +13,8 @@
Redirectingid,
Feature,
)
from feeds.impl.models.external_id_impl import ExternalIdImpl
from feeds.impl.models.redirect_impl import RedirectImpl
from shared.db_models.external_id_impl import ExternalIdImpl
from shared.db_models.redirect_impl import RedirectImpl
from feeds_gen.models.source_info import SourceInfo

targetFeed = Feed(
Expand Down
2 changes: 1 addition & 1 deletion api/tests/unittest/models/test_bounding_box_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from geoalchemy2 import WKTElement

from feeds.impl.models.bounding_box_impl import BoundingBoxImpl
from shared.db_models.bounding_box_impl import BoundingBoxImpl
from feeds_gen.models.bounding_box import BoundingBox

POLYGON = "POLYGON ((3.0 1.0, 4.0 1.0, 4.0 2.0, 3.0 2.0, 3.0 1.0))"
Expand Down
2 changes: 1 addition & 1 deletion api/tests/unittest/models/test_external_id_impl.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest

from shared.database_gen.sqlacodegen_models import Externalid
from feeds.impl.models.external_id_impl import ExternalIdImpl
from shared.db_models.external_id_impl import ExternalIdImpl

external_id_orm = Externalid(
feed_id="feed_id",
Expand Down
8 changes: 4 additions & 4 deletions api/tests/unittest/models/test_gbfs_feed_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

from feeds_gen.models.source_info import SourceInfo
from shared.database_gen.sqlacodegen_models import Gbfsfeed, Location, Gbfsversion
from feeds.impl.models.gbfs_feed_impl import GbfsFeedImpl
from feeds.impl.models.location_impl import LocationImpl
from feeds.impl.models.gbfs_version_impl import GbfsVersionImpl
from feeds.impl.models.bounding_box_impl import BoundingBoxImpl
from shared.db_models.gbfs_feed_impl import GbfsFeedImpl
from shared.db_models.location_impl import LocationImpl
from shared.db_models.gbfs_version_impl import GbfsVersionImpl
from shared.db_models.bounding_box_impl import BoundingBoxImpl

POLYGON = "POLYGON ((3.0 1.0, 4.0 1.0, 4.0 2.0, 3.0 2.0, 3.0 1.0))"

Expand Down
2 changes: 1 addition & 1 deletion api/tests/unittest/models/test_gtfs_dataset_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from geoalchemy2 import WKTElement

from shared.database_gen.sqlacodegen_models import Validationreport, Gtfsdataset, Feed
from feeds.impl.models.gtfs_dataset_impl import GtfsDatasetImpl
from shared.db_models.gtfs_dataset_impl import GtfsDatasetImpl

POLYGON = "POLYGON ((3.0 1.0, 4.0 1.0, 4.0 2.0, 3.0 2.0, 3.0 1.0))"

Expand Down
12 changes: 6 additions & 6 deletions api/tests/unittest/models/test_gtfs_feed_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
Notice,
Feed,
)
from feeds.impl.models.bounding_box_impl import BoundingBoxImpl
from feeds.impl.models.external_id_impl import ExternalIdImpl
from feeds.impl.models.gtfs_feed_impl import GtfsFeedImpl
from feeds.impl.models.latest_dataset_impl import LatestDatasetImpl
from feeds.impl.models.location_impl import LocationImpl
from feeds.impl.models.redirect_impl import RedirectImpl
from shared.db_models.bounding_box_impl import BoundingBoxImpl
from shared.db_models.external_id_impl import ExternalIdImpl
from shared.db_models.gtfs_feed_impl import GtfsFeedImpl
from shared.db_models.latest_dataset_impl import LatestDatasetImpl
from shared.db_models.location_impl import LocationImpl
from shared.db_models.redirect_impl import RedirectImpl
from feeds_gen.models.latest_dataset_validation_report import LatestDatasetValidationReport
from feeds_gen.models.source_info import SourceInfo

Expand Down
8 changes: 4 additions & 4 deletions api/tests/unittest/models/test_gtfs_rt_feed_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
Feed,
)
from feeds_gen.models.source_info import SourceInfo
from feeds.impl.models.gtfs_rt_feed_impl import GtfsRTFeedImpl
from feeds.impl.models.external_id_impl import ExternalIdImpl
from feeds.impl.models.location_impl import LocationImpl
from feeds.impl.models.redirect_impl import RedirectImpl
from shared.db_models.gtfs_rt_feed_impl import GtfsRTFeedImpl
from shared.db_models.external_id_impl import ExternalIdImpl
from shared.db_models.location_impl import LocationImpl
from shared.db_models.redirect_impl import RedirectImpl

targetFeed = Feed(
id="id1",
Expand Down
4 changes: 2 additions & 2 deletions api/tests/unittest/models/test_latest_dataset_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from geoalchemy2 import WKTElement

from shared.database_gen.sqlacodegen_models import Gtfsdataset, Feed, Validationreport, Feature
from feeds.impl.models.bounding_box_impl import BoundingBoxImpl
from feeds.impl.models.latest_dataset_impl import LatestDatasetImpl
from shared.db_models.bounding_box_impl import BoundingBoxImpl
from shared.db_models.latest_dataset_impl import LatestDatasetImpl

POLYGON = "POLYGON ((3.0 1.0, 4.0 1.0, 4.0 2.0, 3.0 2.0, 3.0 1.0))"

Expand Down
2 changes: 1 addition & 1 deletion api/tests/unittest/models/test_location_impl.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from feeds.impl.models.location_impl import LocationImpl
from shared.db_models.location_impl import LocationImpl
from shared.database_gen.sqlacodegen_models import Location as LocationOrm


Expand Down
2 changes: 1 addition & 1 deletion api/tests/unittest/models/test_redirect_id_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from shared.database_gen.sqlacodegen_models import Redirectingid
from shared.database_gen.sqlacodegen_models import Feed
from feeds.impl.models.redirect_impl import RedirectImpl
from shared.db_models.redirect_impl import RedirectImpl

redirect_orm = Redirectingid(
source_id="source_id", target_id="target_id", redirect_comment="comment", target=Feed(stable_id="target_id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import copy
from faker import Faker

from feeds.impl.models.search_feed_item_result_impl import SearchFeedItemResultImpl
from shared.db_models.search_feed_item_result_impl import SearchFeedItemResultImpl
from feeds_gen.models.latest_dataset import LatestDataset
from feeds_gen.models.latest_dataset_validation_report import LatestDatasetValidationReport
from feeds_gen.models.location import Location
Expand Down
2 changes: 1 addition & 1 deletion api/tests/unittest/models/test_validation_report_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from datetime import datetime

from shared.database_gen.sqlacodegen_models import Validationreport, Notice, Feature
from feeds.impl.models.validation_report_impl import ValidationReportImpl
from shared.db_models.validation_report_impl import ValidationReportImpl


class TestValidationReportImpl(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion api/tests/unittest/test_feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from fastapi.testclient import TestClient

from feeds.impl.models.feed_impl import FeedImpl
from shared.db_models.feed_impl import FeedImpl
from shared.database.database import Database
from shared.database_gen.sqlacodegen_models import (
Feed,
Expand Down
Loading