DemocracyClub / EveryElection

:ballot_box_with_check: For recording every election in the UK
https://elections.democracyclub.org.uk/
BSD 3-Clause "New" or "Revised" License
11 stars 14 forks source link

`OrganisationBoundaryReview` object can only be related to one `Organisation` object and one `DivisionSet` object #2227

Open chris48s opened 2 months ago

chris48s commented 2 months ago

Currently an OrganisationBoundaryReview can be related to one Organisation object and one DivisionSet object.

This isn't really true in the real world though. For example

These Electoral Change Orders https://www.legislation.gov.uk/uksi/2019/354/made https://www.legislation.gov.uk/uksi/2019/423/made make changes to both District Wards and County Electoral Divisions in one order, so they affect both a District and County.

This order http://www.legislation.gov.uk/uksi/2014/270/made re-wards the whole of Northern Ireland in a single piece of legislation so it affects 11 different districts.

and

This Boundaries Amendment Order http://www.legislation.gov.uk/ssi/2018/308/made (and all similar orders) necessarily affects 2 neighbouring districts.

These aren't completely isolated examples.

At the moment, the way we seem to have handled this is by creating multiple OrganisationBoundaryReview objects for the same legislation and then linking each one to a different Organisation and DivisionSet. Currently we're trying to sort out some duplicate records that have been incorrectly created but it is hard to work out which are the "good" dupes and which are the "bad" dupes.

Do we like this model? It seems like a better model would be to allow one OrganisationBoundaryReview to be related to many Organisations and many DivisionSets.

What problems would that cause us?

GeoWill commented 2 months ago

I guess it depends what the 'review' is. There's obviously a case that it's the process that gets to the legislation, but I don't know if we're that bothered about catching all the detail of that. The outcome is what we're bothered about, but we do want to track the process as it's going along too.

For example the current NI review process has reports for each district (link). If we wanted to link those then we would want an OrganisationBoundaryReview per Organisation - DivisionSet pair. That's the sort of thing I had in mind when I made the model.

Re. Wards and County Electoral Divisions I can see that there was one review that changed a parish which has knock on effects on district and county divisions, and so having 2 OrganisationBoundaryReview objects is confusing.

Maybe legislation should be what we model as it's the ultimate source of truth, and we're less interested in the process that gets us there. OTOH I quite like the idea of becoming a place people can get information about all reviews happening at different levels of electoral geography; and that feels easier to me with the OrganisationBoundaryReview per DivisionSet model.

chris48s commented 2 months ago

Lets talk about this next week. I can run you through the background in more detail.

The main reason I am thinking the model that [one review = one legislation] would be useful is that we don't have a unique ID for a review or ECO in the data we scrape from LGBCE, so we have to try and match up a review we've scraped from LGBCE to a record in our DB. Our current thinking is that the uksi/2014/270 part of the URL is about the best way to extract a unique ID for a made ECO from the scraped data (the current approach is leading to duplicates of the bad variety), but in the current model we can't rely on that being a unique ID for a OrganisationBoundaryReview record.

GeoWill commented 1 month ago

Drive by -> example of CGR affecting 2 orgs: https://www.legislation.gov.uk/uksi/2024/597/made (Uttlesford and Essex) LGBCE also has an in progress review of Essex. Will be effective from 2025. While CGR from Uttlesford says CED changes are also effective from 2025. I'm not sure exactly how this works.

awdem commented 1 month ago

More examples:

North Yorkshire: https://www.legislation.gov.uk/uksi/2022/328/made Somerset: https://www.legislation.gov.uk/uksi/2022/329/introduction/made

These SCOs affect both county and UTA because they effectively restructure the former into the latter. In the db, currently this is reflected with two boundary review records for the same legislation. This was causing issues with boundary bot that I addressed in this PR: https://github.com/DemocracyClub/EveryElection/pull/2248/

chris48s commented 1 month ago

Note: these two were related to both because the old authority held shadow elections for the new one