Skip to content

Commit

Permalink
Feat: Official Status Tag Update (#869)
Browse files Browse the repository at this point in the history
* Add trigger for tracking `official` field updates in `feed`

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`.

* Removed trigger for logging official tag changes & replaced with direct query update to the 'officialstatushistory' table
  • Loading branch information
AlfredNwolisa authored Jan 10, 2025
1 parent c1e2c57 commit d91489e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions liquibase/changes/official_tag_update.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- Query to update official tag for feeds with contact email in the feed table where the source is mdb

UPDATE public.feed f
SET official = TRUE
FROM public.externalid e
WHERE f.id = e.feed_id
AND f.feed_contact_email LIKE '%@%'
AND e.source = 'mdb';

-- Query to insert a record in officialstatushistory table for feeds with contact email in the feed table where the source is mdb
INSERT INTO public.officialstatushistory (is_official, feed_id, reviewer_email, timestamp, notes)
SELECT
official,
id,
'api@mobilitydata.org',
NOW(),
'Official status tag changed'
FROM public.feed
WHERE feed_contact_email LIKE '%@%'
AND official = TRUE;

0 comments on commit d91489e

Please sign in to comment.