Skip to content

Commit

Permalink
FIX: Update generation script to handle GSS codes differently
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-griffen committed Mar 14, 2024
1 parent 9ceadfc commit 5ec8ccd
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import requests
from tqdm import tqdm

from hub.models import Area
from utils.mapit import (
BadRequestException,
ForbiddenException,
Expand All @@ -27,6 +28,10 @@ class Command(BaseCommand):

out_file = settings.BASE_DIR / "data" / "wildlife_trust_reserves.csv"

con_gss_codes = list(
set([value["gss"] for value in list(Area.objects.values("gss"))])
)

def get_dataframe(self):
if not self._quiet:
self.stdout.write("Downloading data from API")
Expand Down Expand Up @@ -72,7 +77,9 @@ def get_gss_code(self, mapit, postcode):
sleep(60)
return self.get_gss_code(mapit, postcode)
if gss_code:
return gss_code[0]
for code in gss_code:
if code in self.con_gss_codes:
return code

def process_data(self, df):
if not self._quiet:
Expand Down

0 comments on commit 5ec8ccd

Please sign in to comment.