Skip to content

Conversation

@AlfredNwolisa
Copy link
Contributor

@AlfredNwolisa AlfredNwolisa commented Jan 8, 2025

Summary:

This PR contains sql queries to update and set official tags for feeds from with valid contact email that have 'mbd' as their source & logs these changes to the public.officialstatushistory

Key Changes

  1. Includes a batch update query or setting official tags on MDB-sourced feeds with valid contact emails
  2. Added query to log changes for updated to public.officialstatushistory table for audit purposes

This pull request addresses the functionality described in issue https://github.com/MobilityData/mobility-feed-api/issues/851

Expected behavior:

  • MDB-sourced feeds with valid contact emails will be marked as official
  • Database will maintain an audit trail of all official status changes

Snapshot of updated official status tag

Screenshot 2025-01-08 at 4 48 18 PM

Snapshot of officialstatushistory table

Screenshot 2025-01-08 at 4 51 44 PM

Testing tips:

Provide tips, procedures and sample files on how to test the feature.
Testers are invited to follow the tips AND to try anything they deem relevant outside the bounds of the testing tips.

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

  • Run the unit tests with ./scripts/api-tests.sh to make sure you didn't break anything
  • Add or update any needed documentation to the repo
  • Format the title like "feat: [new feature short description]". Title must follow the Conventional Commit Specification(https://www.conventionalcommits.org/en/v1.0.0/).
  • Linked all relevant issues
  • Include screenshot(s) showing how this pull request works and fixes the issue(s)

This commit introduces a PostgreSQL trigger and associated function to log changes to the `official` field in the `public.feed` table. It also includes a query to set the `official` field for feeds meeting specific criteria. This enhances data auditability and ensures change history is recorded in `officialstatushistory`.
@AlfredNwolisa AlfredNwolisa self-assigned this Jan 8, 2025
@AlfredNwolisa AlfredNwolisa linked an issue Jan 8, 2025 that may be closed by this pull request
Comment on lines 17 to 21
-- Trigger to track changes in the official field of the feed table
CREATE TRIGGER track_official_tag_change
AFTER UPDATE OF official ON public.feed
FOR EACH ROW
EXECUTE FUNCTION log_official_tag_change();
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove this trigger as it's not possible to infer the email of the person/system stamping the official field. It's true that for the execution if the [email protected] but subsequence updates the email should be associated with the person staying the official flag.
However, we still need to do the first migration so the officialstatushistory should contain one row for the feeds that were updated in the SQL update in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay. Done

id,
'[email protected]',
NOW(),
'Official status tag changed'
Copy link
Collaborator

Choose a reason for hiding this comment

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

I find this note to be a bit generic.
Maybe you can ask @emmambd for a note that is specific to the operation done here.
Like: Official status set after manual verification of initial DB contents.
Or something like this.
Or maybe it's not important.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Where does this alert show up? I think keeping is general is okay in case there's a world where we do automate this in the future

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@emmambd it shows up as a note in the officialstatushistory table for the feeds i set to official.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If it lives in the DB I think that is sufficient.

@AlfredNwolisa AlfredNwolisa merged commit d91489e into main Jan 10, 2025
3 checks passed
@AlfredNwolisa AlfredNwolisa deleted the official_status_tag_update branch January 10, 2025 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Populate official tag

5 participants