Skip to content

Commit

Permalink
fixed lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
qcdyx committed Mar 29, 2024
1 parent 1f03bde commit d401282
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
24 changes: 11 additions & 13 deletions api/src/feeds/impl/datasets_api_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,13 @@ class DatasetsApiImpl(BaseDatasetsApi):

@staticmethod
def create_dataset_query():
return (
Query(
[
Gtfsdataset,
Gtfsdataset.bounding_box.ST_AsGeoJSON(),
Feed.stable_id,
]
)
.join(Feed, Feed.id == Gtfsdataset.feed_id)
)
return Query(
[
Gtfsdataset,
Gtfsdataset.bounding_box.ST_AsGeoJSON(),
Feed.stable_id,
]
).join(Feed, Feed.id == Gtfsdataset.feed_id)

@staticmethod
def _load_validation_report():
Expand Down Expand Up @@ -86,8 +83,9 @@ def _load_features_validation_report(validation_report_id: str):
"""
This method is for loading features related with a validation report.
"""
query = select(t_featurevalidationreport.c.feature).where(t_featurevalidationreport.c.validation_id == validation_report_id)

query = select(t_featurevalidationreport.c.feature).where(
t_featurevalidationreport.c.validation_id == validation_report_id
)
return Database().session.execute(query).scalars().all()

@staticmethod
Expand Down Expand Up @@ -164,7 +162,7 @@ def get_datasets_gtfs(query: Query, limit: int = None, offset: int = None) -> Li
if notices_for_dataset:
database_validator_report = notices_for_dataset[0].validation_report
features_results = DatasetsApiImpl._load_features_validation_report(database_validator_report.id)
features=sorted([feature for feature in features_results if feature is not None])
features = sorted([feature for feature in features_results if feature is not None])
print(features)
validator_report = ValidationReport(
features=features,
Expand Down
1 change: 0 additions & 1 deletion api/tests/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
VALIDATION_WARNING_NOTICES,
VALIDATION_ERROR_NOTICES,
VALIDATION_ERROR_COUNT_PER_NOTICE,
FEATURE_IDS,
)
from sqlalchemy.exc import SQLAlchemyError
from unittest.mock import patch
Expand Down
10 changes: 4 additions & 6 deletions api/tests/test_utils/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ def populate_database(db: Database):
)
for feature_id in FEATURE_IDS:
db.session.execute(
f"INSERT INTO featurevalidationreport (feature, validation_id) " f"VALUES ('{feature_id}', '{new_validation_report.id}')"
f"INSERT INTO featurevalidationreport (feature, validation_id) "
f"VALUES ('{feature_id}', '{new_validation_report.id}')"
)

for idx, external_id in enumerate(TEST_EXTERNAL_IDS):
Expand Down Expand Up @@ -167,11 +168,8 @@ def populate_database(db: Database):
db.session.execute(f"DELETE FROM gtfsrealtimefeed where id = '{gtfs_rt_feed_id}'")
for feed_id in [*gtfs_feed_ids, gtfs_rt_feed_id]:
db.session.execute(f"DELETE FROM feed where id = '{feed_id}'")

feature_ids_str = ', '.join([f"'{feature_id}'" for feature_id in FEATURE_IDS])
feature_ids_str = ", ".join([f"'{feature_id}'" for feature_id in FEATURE_IDS])
# Delete referencing rows in featurevalidationreport
db.session.execute(f"DELETE FROM featurevalidationreport WHERE feature IN ({feature_ids_str})")
db.session.execute(
f"""DELETE FROM feature where name in ({feature_ids_str})"""
)
db.session.execute(f"""DELETE FROM feature where name in ({feature_ids_str})""")
db.commit()

0 comments on commit d401282

Please sign in to comment.