From 47adae1fe5511be2dd5161eafbf886ca2e87c4e5 Mon Sep 17 00:00:00 2001 From: ray Date: Wed, 3 Apr 2024 15:27:12 -0700 Subject: [PATCH] DBC22-1884: rest stop ID fix --- .../apps/rest/management/commands/purge_rest_stops.py | 7 +++++++ src/backend/apps/rest/tasks.py | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 src/backend/apps/rest/management/commands/purge_rest_stops.py diff --git a/src/backend/apps/rest/management/commands/purge_rest_stops.py b/src/backend/apps/rest/management/commands/purge_rest_stops.py new file mode 100644 index 000000000..6ae84abc8 --- /dev/null +++ b/src/backend/apps/rest/management/commands/purge_rest_stops.py @@ -0,0 +1,7 @@ +from apps.rest.models import RestStop +from django.core.management.base import BaseCommand + + +class Command(BaseCommand): + def handle(self, *args, **options): + RestStop.objects.all().delete() diff --git a/src/backend/apps/rest/tasks.py b/src/backend/apps/rest/tasks.py index 50189a518..81d80c198 100644 --- a/src/backend/apps/rest/tasks.py +++ b/src/backend/apps/rest/tasks.py @@ -9,14 +9,15 @@ def populate_rest_stop_from_data(new_rest_stop_data): - rest_stop_id = new_rest_stop_data.get('rest_stop_id') geometry = new_rest_stop_data.get('geometry') + properties = new_rest_stop_data.get('properties') + rest_stop_id = properties.get('CHRIS_REST_AREA_ID') existing_record = RestStop.objects.filter(rest_stop_id=rest_stop_id).first() data = { 'rest_stop_id': rest_stop_id, 'geometry': geometry, - 'properties': new_rest_stop_data.get('properties'), + 'properties': properties, 'bbox': new_rest_stop_data.get('bbox'), }