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

Multiple Geographies #331

Merged
merged 16 commits into from
Nov 21, 2023
Merged

Conversation

alexander-griffen
Copy link
Contributor

@alexander-griffen alexander-griffen commented Oct 26, 2023

So far, this PR:

  • Downloads the new geographies
  • Alters the Area pages to better handle them

What is required is:

  • Allowing the map and table on the explore page to handle the two sets of geographies - with a switch?
  • Making the area page View less inefficient (probably by moving the lookups to be downloaded to the Area model?)

For #256

@codecov
Copy link

codecov bot commented Oct 26, 2023

Codecov Report

Attention: 17 lines in your changes are missing coverage. Please review.

Comparison is base (e2a12cc) 82.50% compared to head (228f87c) 82.82%.

Files Patch % Lines
hub/mixins.py 50.00% 7 Missing and 1 partial ⚠️
hub/models.py 80.76% 5 Missing ⚠️
hub/management/commands/base_importers.py 60.00% 4 Missing ⚠️
Additional details and impacted files
@@                      Coverage Diff                      @@
##           multiple-geometry-staging     #331      +/-   ##
=============================================================
+ Coverage                      82.50%   82.82%   +0.32%     
=============================================================
  Files                             87       90       +3     
  Lines                           2669     2725      +56     
  Branches                         275      278       +3     
=============================================================
+ Hits                            2202     2257      +55     
  Misses                           404      404              
- Partials                          63       64       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Fill the existing constituencies with the correct AreaType
(2010 parliamentary constituencies)
@zarino zarino force-pushed the 256-multiple-geographies branch from af1a72c to 5565933 Compare October 27, 2023 14:27
Copy link
Member

@zarino zarino left a comment

Choose a reason for hiding this comment

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

@alexander-griffen I‘ve cherry-picked the five useful commits out of your original branch and onto main, so the PR diff looks much cleaner now! (Your original branch has been backed up to 256-multiple-geographies-backup in case we ever need it again.)

The "This is a 2010 constituency" card at the top of the Area page looks fine.

I’ll sort out a constituency generation switcher on the Explore page next week.

In the meantime, I‘ve left a few questions / comments inline.

hub/management/commands/import_new_constituencies.py Outdated Show resolved Hide resolved
print("Importing Areas")
df = pd.read_csv(self.data_file)
area_type, created = AreaType.objects.get_or_create(
name="2023 Parliamentary Constituency",
Copy link
Member

Choose a reason for hiding this comment

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

It looks like we’ve made a decision, elsewhere (eg: https://pages.mysociety.org/2025-constituencies/) to call these "2025" constituencies. So should we use 2025 Parliamentary Constituency and WMC25 here? /cc @ajparsons

Copy link
Member

Choose a reason for hiding this comment

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

FWIW I discussed this with @ajparsons and we think we should refer to these new constituencies as either "2025 constituencies" or "Future constituencies" (if we want to hedge our bets) when we’re limited for space, and "Constituencies at the next election" if we have more space.

I see @struan has already modified import_new_constituencies.py to use the latter 👍

@@ -388,6 +388,17 @@ def shader_value(self, area):
return None, None, None


class AreaType(models.Model):
Copy link
Member

Choose a reason for hiding this comment

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

PS @alexander-griffen I learned a few weeks ago that you can pass a string to models.ForeignKey() when you want to refer to a model that’s defined further down in the file. So, in this case, a line like…

area_type = models.ForeignKey("AreaType", on_delete=models.CASCADE, null=True)

…would have saved you having to shuffle this Class further up the file.

@@ -39,10 +39,40 @@ <h1 class="m-0">{{ area.name }}</h1>
</div>
</div>
<div class="col-lg-9 offset-xl-1">

{% if area_type == "WMC" %}
<div class="card flex-grow-1 dataset-card">
Copy link
Member

Choose a reason for hiding this comment

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

It’d be good to have one of these cards on the WMC23 pages too, but going the other way (ie: saying "This is a 2025 (2023?) constituency … it replaced the following 2010 constituency/ies: …"

Copy link
Member

Choose a reason for hiding this comment

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

I'm going to fix this as part of #337

hub/templates/hub/area.html Outdated Show resolved Hide resolved
@struan struan self-requested a review October 30, 2023 11:57
Copy link
Member

@struan struan left a comment

Choose a reason for hiding this comment

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

Mostly looks fine. one comment about the geometry stuff which is hampered by lack of data.

hub/management/commands/import_new_constituencies.py Outdated Show resolved Hide resolved
hub/management/commands/import_new_constituencies.py Outdated Show resolved Hide resolved
@struan
Copy link
Member

struan commented Nov 6, 2023

A further issue is that GSS codes turn out not be unique across the two different boundary sets so we need to update import scripts etc to distinguish areas based on GSS/Name and area type.

I am going to add some methods to the Area model for looking up areas so we can consolidate this in once place.

@struan struan requested a review from zarino November 9, 2023 16:23
@struan struan changed the base branch from main to multiple-geometry-staging November 9, 2023 16:23
Copy link
Member

@zarino zarino left a comment

Choose a reason for hiding this comment

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

@struan @alexander-griffen I’ve added a commit that fixes a few of the comments I left last week. The other open comments are all beyond my ability.

Generally, this seems ok. It’d be nice to get those outstanding comments addressed though.

@struan struan requested a review from zarino November 13, 2023 17:15
Copy link
Member

@zarino zarino left a comment

Choose a reason for hiding this comment

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

@struan I think this is all looking good so far. Obviously we’re missing all the WMC23 datasets, so the Area page for a WMC23 constituency looks particularly empty/broken. Do you want to implement updated import scripts as part of this PR, or create a separate ticket and PR for it?

@struan struan force-pushed the 256-multiple-geographies branch from 863476e to 228f87c Compare November 21, 2023 14:50
@struan struan merged commit 228f87c into multiple-geometry-staging Nov 21, 2023
6 of 7 checks passed
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