Skip to content

Commit

Permalink
KLS-654 add celery task for Market Guides ingest
Browse files Browse the repository at this point in the history
  • Loading branch information
TOE703 committed Jul 7, 2023
1 parent c28f27f commit 20cd9a1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 7 additions & 5 deletions dataservices/management/commands/import_market_guides_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ def add_arguments(self, parser):
)

def handle(self, *args, **options):
for k, v in self.command_table_view.items():
if MarketGuidesDataIngestionCommand().should_ingestion_run(v['view_name'], v['table_name']):
self.stdout.write(self.style.NOTICE(f'Running {k}'))
call_command(k, **options)
call_command('import_metadata_source_data', table=v['table_name'])
for command_name, table_view_names in self.command_table_view.items():
if MarketGuidesDataIngestionCommand().should_ingestion_run(
table_view_names['view_name'], table_view_names['table_name']
):
self.stdout.write(self.style.NOTICE(f'Running {command_name}'))
call_command(command_name, **options)
call_command('import_metadata_source_data', table=table_view_names['table_name'])

self.stdout.write(self.style.SUCCESS('All done, bye!'))
8 changes: 7 additions & 1 deletion dataservices/tasks.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import requests
from django.core.management import call_command
from django.db import transaction

from conf.celery import app
from dataservices.models import CIAFactbook
from dataservices.models import CIAFactbook, Metadata


@app.task(autoretry_for=(TimeoutError,))
Expand All @@ -18,3 +19,8 @@ def load_cia_factbook_data_from_url(url):
country_name = data['countries'][country]['data']['name']
country_data = data['countries'][country]['data']
CIAFactbook(country_key=country, country_name=country_name, factbook_data=country_data).save()


@app.task()
def run_market_guides_ingest():
call_command('import_market_guides_data')

0 comments on commit 20cd9a1

Please sign in to comment.