Skip to content

Commit

Permalink
Agrego logging a la indexación de metadatos
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaslavandeira committed Mar 27, 2018
1 parent 604ad08 commit b634e28
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,24 @@

from . import strings

logging.getLogger(__name__)
logger = logging.getLogger(__name__)


class MetadataIndexer(object):

def __init__(self, data_json):
self.data_json = data_json
self.elastic = ElasticInstance.get()
logger.info('Hosts de ES: %s', self.elastic.transport.hosts)

def index(self):
logger.info(u'Inicio de la indexación de metadatos')
self.init_index()

actions = self.scrap_datajson()

self.index_actions(actions)
logger.info(u'Fin de la indexación de metadatos')

# noinspection PyProtectedMember
def init_index(self):
Expand All @@ -33,7 +37,7 @@ def init_index(self):
def index_actions(self, actions):
for success, info in parallel_bulk(self.elastic, actions):
if not success:
logging.info(strings.INDEXING_ERROR, info)
logger.info(strings.INDEXING_ERROR, info)

def scrap_datajson(self):
themes = self.get_themes(self.data_json['themeTaxonomy'])
Expand Down Expand Up @@ -62,6 +66,7 @@ def get_dataset(self, identifier):
for dataset in self.data_json['dataset']:
if dataset['identifier'] == identifier:
return dataset
raise ValueError(u'Identifier no encontrado: {}'.format(identifier))

@staticmethod
def get_themes(theme_taxonomy):
Expand Down

0 comments on commit b634e28

Please sign in to comment.