Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes for import scripts #613

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

zarino
Copy link
Member

@zarino zarino commented Sep 24, 2024

  • Reinstates handling of 2010 WMCs in import scripts, and removes the no longer required import_new_constituencies command
  • Fixes a common bug where a number of import scripts used QuerySet.get() instead of QuerySet.filter(), which meant they failed when run on a database that contained both WMC and WMC23 AreaTypes.
  • Marks a number of import scripts as either outdated or broken, in the run_all_import_scripts management command – something to follow up on later!!
  • Turns script/import-all-data into a dumb wrapper around ./manage.py run_all_import_scripts, to reduce duplication

The upshot of this is that—as long as you have all the required source data in the /data directory—a fresh docker compose up and then script/dev-command ./manage.py run_all_import_scripts successfully gets you a largely complete copy of the live site. (What’s missing, of course, is any scripts skipped in run_all_import_scripts, and any featured or is_public states on DataSets, which must be set manually via the Django admin.)

@struan I wasn’t sure whether to leave your debugging commits in, or remove them? Also, should we try to fix the five broken import scripts (the ValueError and JSONDecodeError ones now listed in run_all_import_scripts) as part of this PR, or is that something for a separate ticket?

struan and others added 8 commits September 18, 2024 15:14
We removed 2010 WMC constituencies from the import scripts back in July,
because we figured all 2010 data had already been imported into the live
site, and we wouldn’t need to import any more.

But it’s actually useful to be able to recreate the situation of the live
site (with multiple generations of WMCs) in local development too, which
means we need the import scripts to keep working with WMCs, rather than
relying on developers just having the right data already in their local
environments.

This commit reinstates the WMC (rather than WMC23) AreaType, and updates
our mapit utility function to accept a `generation` parameter that will
easily allow us to change the MapIt generation in future again too.

With both 2010 and 2023 constituencies coming straight from MapIt now,
there is no longer any need for the import_new_constituencies command.
These import scripts all used QuerySet.get() insted of QuerySet.filter()
which was causing an exception when both WMC and WMC23 AreaTypes were
present in the database.
Also, run the scripts alphabetically for easier debugging.
@zarino zarino requested a review from struan September 24, 2024 16:34
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