Skip to content

Add relevant ONSPD records to the postcode collection worker#556

Merged
KludgeKML merged 4 commits into
mainfrom
onspd-quality-promote
Jan 27, 2025
Merged

Add relevant ONSPD records to the postcode collection worker#556
KludgeKML merged 4 commits into
mainfrom
onspd-quality-promote

Conversation

@KludgeKML
Copy link
Copy Markdown
Contributor

@KludgeKML KludgeKML commented Jan 16, 2025

It's possible that the low quality ONSPD postcode data contains postcodes that are small/active postcodes (ie not retired and not Large User Postcodes), which might therefore exist in the OS Places database, but which we missed in our initial import and have therefore been filled in with ONSPD data. This would mean they could never be updated, since ONSPD and OS Places data hasn't mixed until now.

This PR adds the potentially upgradeable records (about 15k of them) into the postcode collection worker's candidate pool, ensuring they are checked once a week. We handle them slightly differently from OS Places records (if OS places finds no data for them, we don't want to delete them, but we do touch them so that they won't be checked until the next cycle).

Before merging we should run this code in integration for a day or two to confirm it's working and see how many records it updates.

https://trello.com/c/zEZxyZol/425-check-whether-locations-api-low-quality-records-could-be-replaced-with-higher-quality-ones, Jira issue PNP-9228

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

⚠️ Coverage note: test suite is set to fail if coverage drops below 100%. If you need to merge in an emergency, you will have to temporarily change branch protection rules. ⚠️

Follow these steps if you are doing a Rails upgrade.

@KludgeKML KludgeKML force-pushed the onspd-quality-promote branch from e33a463 to efa5de6 Compare January 16, 2025 16:55
@KludgeKML KludgeKML changed the title Onspd quality promote Add relevant ONSPD records to the postcode collection worker Jan 16, 2025
@KludgeKML KludgeKML marked this pull request as ready for review January 16, 2025 16:59
@KludgeKML KludgeKML changed the title Add relevant ONSPD records to the postcode collection worker [DO NOT MERGE] Add relevant ONSPD records to the postcode collection worker Jan 16, 2025
@KludgeKML KludgeKML marked this pull request as draft January 16, 2025 17:00
@KludgeKML KludgeKML force-pushed the onspd-quality-promote branch from efa5de6 to 08a27fa Compare January 20, 2025 09:41
…he check.

- Some ONSPD postcodes (small, active) should be eligible for checking against OS Places API, in case higher quality data exists for them.
- previously we would only get os_places records in the update_postcode method. Now we might get onspd records, and if os_places data is returned for them we should update the results and source to promote them to the higher-quality data.
- We don't want to delete onspd records if no os places data exists for them,
  so add a test into the rescue which deletes os_places records and touches
  onspd records so they don't come up again till the next round (essentially
  making sure they're checked once a week).
- This table records ONSPD imports. We record the URL for reference, but the main detail is the created_at value, which we can use to determine whether a new dataset is available.
- Previously we've used the maximum updated_at value for any ONSPD postcode to check this, but now we're handling that the same as the updated_at for OS Places records, so it becomes unreliable as an indicator of imports (ie we may touch it when we try and fail to update the record to higher-quality OS Places record so that we don't constantly try to update records that OS Places doesn't know about).
- This is also just a clearer, simpler way of doing this, and gives us a better audit trail of ONSPD updates.
@KludgeKML KludgeKML force-pushed the onspd-quality-promote branch from 9ae0522 to e6dfcce Compare January 27, 2025 09:19
@KludgeKML KludgeKML marked this pull request as ready for review January 27, 2025 09:56
@KludgeKML KludgeKML changed the title [DO NOT MERGE] Add relevant ONSPD records to the postcode collection worker Add relevant ONSPD records to the postcode collection worker Jan 27, 2025
Copy link
Copy Markdown
Contributor

@deborahchua deborahchua left a comment

Choose a reason for hiding this comment

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

LTGM

@KludgeKML KludgeKML merged commit 9ecbba0 into main Jan 27, 2025
@KludgeKML KludgeKML deleted the onspd-quality-promote branch January 27, 2025 10:41
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.

2 participants