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)