refactor: rearrange count_deleted_entities to run once per dataset#545
Merged
tombrooks248 merged 2 commits intoMay 12, 2026
Merged
Conversation
efc3d39 to
1b51013
Compare
1b51013 to
d7df1a4
Compare
eveleighoj
approved these changes
May 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
As part of the
assemble-and-bake pipelinestep weRun dataset expectations...this includes a function calledcount_deleted_entities.count_deleted_entitiesmake one HTTP request to datasette per organisation (for brownfield-site that is 342 orgs as defined incollection-task/pipeline/expect.csv), different pipelines have different numbers of orgs but in some worst-case pipelines we are talking hundreds of HTTP requests to datasette per dataset.This PR refactors that code so that it makes the HTTP request once per dataset, getting data for multiple organisations at once, this should reduce the load on datasette throughout the night.
Why
Datasette is getting overwhelmed between the hours of 1am and 3am each night, because of all of these HTTP requests. I believe refactoring these requests to consolidate them will reduce the load on datasettee each night and enable the pipelines to run faster.
Tests
So all the automated tests are passing as you can see.
I have run the pipeline locally on
ownership-statusandbrownfield-siteeverything seemed to run fine, no errors or failures.When ran locally - brownfield-site checked the 342 orgs and produced what looks like 312 passing, 30 genuine data quality failures (organisations with missing entities), which I guess seems about right.
Related Tickets & Documents
QA Instructions, Screenshots, Recordings
Please replace this line with instructions on how to test your changes, a note
on the devices and browsers this has been tested on, as well as any relevant
images for UI changes.
Added/updated tests?
We encourage you to keep the code coverage percentage at 80% and above. Please refer to the Digital Land Testing Guidance for more information.
have not been included
[optional] Are there any post deployment tasks we need to perform?
[optional] Are there any dependencies on other PRs or Work?