diff --git a/src/backend/apps/rest/management/__init__.py b/src/backend/apps/rest/management/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/backend/apps/rest/management/commands/__init__.py b/src/backend/apps/rest/management/commands/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/backend/apps/rest/management/commands/populate_rest_stops.py b/src/backend/apps/rest/management/commands/populate_rest_stops.py new file mode 100644 index 00000000..5e5b91d7 --- /dev/null +++ b/src/backend/apps/rest/management/commands/populate_rest_stops.py @@ -0,0 +1,7 @@ +from apps.rest.tasks import populate_all_rest_stop_data +from django.core.management.base import BaseCommand + + +class Command(BaseCommand): + def handle(self, *args, **options): + populate_all_rest_stop_data() diff --git a/src/backend/apps/rest/tasks.py b/src/backend/apps/rest/tasks.py index 090cb0f0..50189a51 100644 --- a/src/backend/apps/rest/tasks.py +++ b/src/backend/apps/rest/tasks.py @@ -1,8 +1,8 @@ import logging from apps.feed.client import FeedClient -from apps.shared.enums import CacheKey from apps.rest.models import RestStop +from apps.shared.enums import CacheKey from django.core.cache import cache logger = logging.getLogger(__name__) @@ -11,7 +11,7 @@ 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') - + existing_record = RestStop.objects.filter(rest_stop_id=rest_stop_id).first() data = { 'rest_stop_id': rest_stop_id, @@ -35,4 +35,4 @@ def populate_all_rest_stop_data(): populate_rest_stop_from_data(rest_stop_data) # Rebuild cache - cache.delete(CacheKey.REGIONAL_WEATHER_LIST) \ No newline at end of file + cache.delete(CacheKey.REGIONAL_WEATHER_LIST)