Skip to content

upgrade uk-election-timetables, add notice_of_election_deadline and sopn_publish_deadline fields#2613

Open
chris48s wants to merge 7 commits into
masterfrom
timetables5
Open

upgrade uk-election-timetables, add notice_of_election_deadline and sopn_publish_deadline fields#2613
chris48s wants to merge 7 commits into
masterfrom
timetables5

Conversation

@chris48s

@chris48s chris48s commented Jul 8, 2026

Copy link
Copy Markdown
Member

PR notes

This PR upgrades EE to use uk-election-timetables==5.0.0
Release notes: https://github.com/DemocracyClub/uk-election-timetables/releases/tag/5.0.0

Most of the churn here is related to

  • Making use of the new notice_of_election_deadline and sopn_publish_deadline properties
  • Adding unit tests

I'll leave some comments inline calling out specific things.

Once this is in, DemocracyClub/aggregator-api#642 makes sense

So

Make sense to all merge as a block

Then we're on to moving downstream apps to remove use of uk-election-timetables + consume the API instead

@coveralls

coveralls commented Jul 8, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 71.484% (+0.4%) from 71.069% — timetables5 into master

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is another migration that is going to touch the modified date on basically every ballot object in EE
I do at least know this time round that it will break the EE --> YNR sync and what to do about it when it does

self.assert_timetable_fields_all_none(election_group)
self.assert_timetable_fields_all_none(org_group)

def test_nothern_ireland_ballot(self):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is a test I should have really added in #2608

Figured I might as well do it here

self.assert_timetable_fields_all_none(org_group)


class TestCleanMethod(TestCase):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We didn't have tests for the clean() method at all and this PR adds complexity to it
I told a LLM to generate tests for it and then did a review/tidy up on it. So this block of ~200 lines is mostly LLM output with a few edits from me.

1. make migration faster by using bulk_update to
   reduce the number of round-trips to the db
2. fix backwards migration to restore City of London
   SOPN dates to previous state
@chris48s chris48s requested a review from symroe July 8, 2026 13:14

@symroe symroe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approving even though I had a comment about the migration. Everything else looks fine and that migration doesn't really matter if you think it'll run ok.


def backfill_new_timetable_fields(apps, schema_editor):
Election = apps.get_model("elections", "Election")
for election in Election.private_objects.using(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe this doesn't matter for a one off query, but I reckon you can use exclude() here to catch some of the continue cases below? I also suspect it would help to use annotate to attach the territory_code(s), or at least use select_related with only() to get the fields, rather than making n+1 queries in the migration. If this times out, it could be a bit of a pain to unpick.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wrote the above before seeing the later commit, but I think some of these points stand still? Feel free to ignore if you think it's ok

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.

3 participants