File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change 66from elasticsearch import Elasticsearch
77from mypy_boto3_s3 import S3Client
88
9+ from findthatpostcode .areatypes import AreaTypeEnum
910from findthatpostcode .crud .utils import get_or_404
1011from findthatpostcode .schema import Area , Postcode
1112from findthatpostcode .schema .db import Area as AreaDocument
@@ -75,13 +76,15 @@ def get_example_postcodes(
7576 return []
7677
7778
78- def get_child_areas (area : Area , areatype : str , es : Elasticsearch ) -> list [Area ]:
79+ def get_child_areas (
80+ area : Area , areatype : AreaTypeEnum , es : Elasticsearch
81+ ) -> list [Area ]:
7982 query = {
8083 "query" : {
8184 "bool" : {
8285 "filter" : [
8386 {"term" : {"parent.keyword" : area .code }},
84- {"term" : {"type.keyword" : areatype }},
87+ {"term" : {"type.keyword" : areatype . value }},
8588 ]
8689 }
8790 }
Original file line number Diff line number Diff line change 11from fastapi import APIRouter
22
3+ from findthatpostcode .areatypes import AreaTypeEnum
34from findthatpostcode .crud .areas import (
45 get_area ,
56 get_area_boundary ,
@@ -52,7 +53,7 @@ async def read_example_postcodes(
5253 tags = ["GeoJSON" ],
5354)
5455async def read_area_children_geojson (
55- areacode : str , areatype : str , es : ElasticsearchDep , s3_client : S3Dep
56+ areacode : str , areatype : AreaTypeEnum , es : ElasticsearchDep , s3_client : S3Dep
5657) -> AreaGeoJSON :
5758 area = get_area (areacode , es )
5859 areas = get_child_areas (area , areatype , es )
@@ -68,7 +69,7 @@ async def read_area_children_geojson(
6869
6970@router .get ("/{areacode}/children/{areatype}" , response_model_exclude_unset = True )
7071async def read_area_children (
71- areacode : str , areatype : str , es : ElasticsearchDep
72+ areacode : str , areatype : AreaTypeEnum , es : ElasticsearchDep
7273) -> list [AreaResponse ]:
7374 area = get_area (areacode , es )
7475 return get_child_areas (area , areatype , es )
You can’t perform that action at this time.
0 commit comments