Skip to content

Commit

Permalink
feat: add polling stations to report map
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquimds committed Jul 3, 2024
1 parent cca9e24 commit 1b56a61
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 28 deletions.
16 changes: 16 additions & 0 deletions hub/graphql/types/model_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@

from hub import models
from hub.enrichment.sources import builtin_mapping_sources
from hub.enrichment.sources.electoral_commission_postcode_lookup import (
electoral_commision_address_lookup,
electoral_commision_postcode_lookup,
)
from hub.graphql.context import HubDataLoaderContext
from hub.graphql.dataloaders import (
FieldDataLoaderFactory,
FieldReturningListDataLoaderFactory,
ReverseFKWithFiltersDataLoaderFactory,
filterable_dataloader_resolver,
)
from hub.graphql.types.electoral_commission import ElectoralCommissionPostcodeLookup
from hub.graphql.types.geojson import MultiPolygonFeature, PointFeature
from hub.graphql.types.postcodes import PostcodesIOResult
from hub.graphql.utils import attr_field, dict_key_field, fn_field
Expand Down Expand Up @@ -660,6 +665,17 @@ class MapReportMemberFeature(PointFeature):
id: Optional[str]
properties: Optional[GenericData]

# TODO: move this somewhere more rational
@strawberry_django.field
async def electoral_commission(
self, address_slug: Optional[str] = None
) -> Optional[ElectoralCommissionPostcodeLookup]:
if address_slug:
return await electoral_commision_address_lookup(address_slug)
if self.properties:
return await electoral_commision_postcode_lookup(self.properties.postcode)
return None


@strawberry.enum
class AnalyticalAreaType(Enum):
Expand Down
4 changes: 2 additions & 2 deletions nextjs/src/__generated__/gql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1b56a61

Please sign in to comment.