MobilityData / mobility-feed-api

Apache License 2.0
9 stars 4 forks source link

feat: added WIP flag to feeds #812

Closed cka-y closed 1 week ago

cka-y commented 1 week ago

Summary: This pull request introduces visibility restrictions for work-in-progress (WIP) feeds in feeds_api_impl.py and search_api_impl.py, based on user email domains. It includes a new function to determine if a user’s email is restricted, updating query filters accordingly to enforce feed visibility rules. Additionally, a new SQL script is included to update the database schema and refresh the materialized view to support these changes.

Expected Behavior: Feeds marked with an internal status of "WIP" are only visible to users with email domains ending in @mobilitydata.org. Users with other domains will not see these WIP feeds.

Testing Instructions:

  1. Set up a local database and run the populate script.
  2. Update the internal status of selected feeds to "WIP" in the database.
  3. Run the API locally.
  4. Make requests to the gtfs, gtfs_rt, and feeds endpoints, as well as the search functionality, while setting the x-goog-authenticated-user-email header to emails ending with both @mobilitydata.org and non-@mobilitydata.org domains.
  5. Verify that only users with @mobilitydata.org emails can view WIP feeds.

Testers are encouraged to follow these instructions but are also welcome to explore other test cases to ensure robust behavior outside the listed scenarios.

Please make sure these boxes are checked before submitting your pull request - thanks!

cka-y commented 1 week ago

Integration tests are expected to fail for this PR due to changes in the database schema. Specifically, the error encountered is:

psycopg2.errors.UndefinedColumn: column feed.operational_status does not exist
LINE 1: ...ed_contact_email, feed.provider AS feed_provider, feed.opera...

View full logs for additional details.

davidgamez commented 1 week ago

Integration tests are expected to fail for this PR due to changes in the database schema. Specifically, the error encountered is:

psycopg2.errors.UndefinedColumn: column feed.operational_status does not exist
LINE 1: ...ed_contact_email, feed.provider AS feed_provider, feed.opera...

View full logs for additional details.

This makes sense. When we added the integration tests pointing to QA, we predicted that in cases of schema changes, this step would fail as a guardrail for merging. However, it is still a great check for PRs that don't introduce a schema change on the main tables.