From f882516a31923da30fb97fa996120a0365cb9495 Mon Sep 17 00:00:00 2001 From: Lucas Lavandeira <19612265+lucaslavandeira@users.noreply.github.com> Date: Fri, 16 Mar 2018 13:51:00 -0300 Subject: [PATCH] Modifico el management command de metadatos para aceptar varias URLs/ leer de los Node por default --- .../management/commands/index_metadata.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/series_tiempo_ar_api/apps/metadata/management/commands/index_metadata.py b/series_tiempo_ar_api/apps/metadata/management/commands/index_metadata.py index 6027619b..73768223 100644 --- a/series_tiempo_ar_api/apps/metadata/management/commands/index_metadata.py +++ b/series_tiempo_ar_api/apps/metadata/management/commands/index_metadata.py @@ -4,6 +4,7 @@ from django.core.management import BaseCommand from pydatajson import DataJson +from series_tiempo_ar_api.apps.management.models import Node from series_tiempo_ar_api.apps.metadata.indexer.metadata_indexer import MetadataIndexer @@ -13,11 +14,17 @@ class Command(BaseCommand): def add_arguments(self, parser): - parser.add_argument('datajson_url') + parser.add_argument('datajson_url', nargs='*') def handle(self, *args, **options): - try: - data_json = DataJson(options['datajson_url']) - MetadataIndexer(data_json).index() - except Exception as e: - logger.exception(u'Error en la lectura del catálogo: %s', e) + if options['datajson_url']: + urls = options['datajson_url'] + else: + urls = [node.catalog_url for node in Node.objects.filter(indexable=True)] + + for url in urls: + try: + data_json = DataJson(url) + MetadataIndexer(data_json).index() + except Exception as e: + logger.exception(u'Error en la lectura del catálogo: %s', e)