Skip to content

Commit

Permalink
Merge a7d1605 into 6a0204a
Browse files Browse the repository at this point in the history
  • Loading branch information
Glignos committed Jan 6, 2020
2 parents 6a0204a + a7d1605 commit c3980c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False

nitpick_ignore = [('py:class', 'Record')]

# -- Options for HTML output ----------------------------------------------
html_theme = 'alabaster'
Expand Down
11 changes: 7 additions & 4 deletions invenio_indexer/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class RecordIndexer(object):
these requests in bulk.
"""

record_cls = Record

def __init__(self, search_client=None, exchange=None, queue=None,
routing_key=None, version_type=None, record_to_index=None):
"""Initialize indexer.
Expand Down Expand Up @@ -140,7 +142,7 @@ def index_by_id(self, record_uuid, **kwargs):
:param record_uuid: Record identifier.
:param kwargs: Passed to :meth:`RecordIndexer.index`.
"""
return self.index(Record.get_record(record_uuid), **kwargs)
return self.index(self.record_cls.get_record(record_uuid), **kwargs)

def delete(self, record, **kwargs):
"""Delete a record.
Expand All @@ -165,7 +167,7 @@ def delete_by_id(self, record_uuid, **kwargs):
:param record_uuid: Record identifier.
:param kwargs: Passed to :meth:`RecordIndexer.delete`.
"""
self.delete(Record.get_record(record_uuid), **kwargs)
self.delete(self.record_cls.get_record(record_uuid), **kwargs)

def bulk_index(self, record_id_iterator):
"""Bulk index records.
Expand Down Expand Up @@ -275,7 +277,8 @@ def _delete_action(self, payload):
"""
index, doc_type = payload.get('index'), payload.get('doc_type')
if not (index and doc_type):
record = Record.get_record(payload['id'], with_deleted=True)
record = self.record_cls.get_record(
payload['id'], with_deleted=True)
index, doc_type = self.record_to_index(record)
index, doc_type = self._prepare_index(index, doc_type)

Expand All @@ -292,7 +295,7 @@ def _index_action(self, payload):
:param payload: Decoded message body.
:returns: Dictionary defining an Elasticsearch bulk 'index' action.
"""
record = Record.get_record(payload['id'])
record = self.record_cls.get_record(payload['id'])
index, doc_type = self.record_to_index(record)

arguments = {}
Expand Down

0 comments on commit c3980c4

Please sign in to comment.