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

Electoral data vis upgrades #206

Merged
merged 36 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
2ffc205
Handle percentage values in aggregations, closes MAP-975
janbaykara Jan 31, 2025
2398ff3
Fix a problem with JSON encoding/decoding and pandas and importing nu…
janbaykara Feb 1, 2025
3c8987a
Display percentage-based election results
janbaykara Feb 1, 2025
2a2c631
Display what electoral data refers to, in cases of overlap
janbaykara Feb 1, 2025
64bafd2
WIP new statistical API
janbaykara Feb 2, 2025
90572bf
WIP — group by beginning to work
janbaykara Feb 2, 2025
4f5a143
Grouping works nicely now
janbaykara Feb 2, 2025
9836778
X
janbaykara Feb 2, 2025
ce8ad59
Consistently return numeric data
janbaykara Feb 2, 2025
319c89c
Add a default agg operation arg
janbaykara Feb 2, 2025
b14b582
Use formulas to doctor existing columns, if you want
janbaykara Feb 2, 2025
e4687d9
Group by arbitrary keys to get stats for bar charts and other data vis
janbaykara Feb 2, 2025
588d425
Recalculate electoral stats in case formulas have doctored agg values
janbaykara Feb 2, 2025
bdac874
Generate zod schema for new stats API
janbaykara Feb 2, 2025
18005a2
Make the new statistical API usable in the frontend
janbaykara Feb 2, 2025
39783db
Display place labels / percentages when using the new statistical api
janbaykara Feb 2, 2025
9c3b795
MVP party shading for choropleth
janbaykara Feb 3, 2025
d656e3b
Fix UI
janbaykara Feb 3, 2025
1245987
Sync choropleth and electoral display, fix electoral displays
janbaykara Feb 3, 2025
164eb8e
Separate visibility for place name and statistical values
janbaykara Feb 3, 2025
03df101
Highlight winner in election displays
janbaykara Feb 3, 2025
b42f06d
Fix Ignore toggle
janbaykara Feb 3, 2025
9e55b16
Change Reform to UKIP purple
janbaykara Feb 3, 2025
8ede199
Add light borders around select boxes
janbaykara Feb 3, 2025
1d88c3a
Show legend where useful
janbaykara Feb 3, 2025
3325cd9
Compact tabs
janbaykara Feb 3, 2025
cbee9d1
Sort out map labels
janbaykara Feb 3, 2025
cf3c0b5
Lint
janbaykara Feb 3, 2025
4bee2b1
Enable UK-wide area explorer
janbaykara Feb 3, 2025
0acfdd0
Fix old choropleth
janbaykara Feb 3, 2025
80f0258
More fixes for the statistical API
janbaykara Feb 3, 2025
04d1f3d
Fix drag/drop
janbaykara Feb 3, 2025
a4a3655
WIP statistical summary widget
janbaykara Feb 3, 2025
8bba0a8
Align all the widgets
janbaykara Feb 3, 2025
9d8a36e
Merge branch 'main' into electoral-displays
joaquimds Feb 3, 2025
c96f167
fix: lint
joaquimds Feb 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions hub/graphql/permissions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from django.contrib.auth.models import AbstractBaseUser

from hub import models


def check_user_can_view_source(user: AbstractBaseUser | str, source_id: str):
external_data_source = models.ExternalDataSource.objects.get(pk=source_id)
permissions = models.ExternalDataSource.user_permissions(user, external_data_source)
if not permissions.get("can_display_points") or not permissions.get(
"can_display_details"
):
raise ValueError(
f"User {user} does not have permission to external data source: {source_id}"
)
11 changes: 11 additions & 0 deletions hub/graphql/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from gqlauth.user.queries import UserQueries
from graphql import GraphQLError
from strawberry.extensions import QueryDepthLimiter
from strawberry.scalars import JSON
from strawberry.types import ExecutionContext
from strawberry_django import mutations as django_mutations
from strawberry_django.optimizer import DjangoOptimizerExtension
Expand Down Expand Up @@ -126,6 +127,16 @@ class Query(UserQueries):
choropleth_data_for_source: List[model_types.GroupedDataCount] = (
model_types.choropleth_data_for_source
)
statistics: Optional[List[JSON]] = strawberry_django.field(
resolver=model_types.statistics,
extensions=[IsAuthenticated()],
)
statistics_for_choropleth: Optional[List[model_types.GroupedDataCount]] = (
strawberry_django.field(
resolver=model_types.statistics_for_choropleth,
extensions=[IsAuthenticated()],
)
)

@strawberry.field
def test_data_source(
Expand Down
Loading