Skip to content

Commit

Permalink
indexer: better code
Browse files Browse the repository at this point in the history
* Eliminates exceptions for bulk indexing.
* Better code with sourcery suggestions.

Co-Authored-by: Peter Weber <[email protected]>
  • Loading branch information
rerowep committed Aug 2, 2022
1 parent d1e5940 commit 6114715
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 75 deletions.
12 changes: 9 additions & 3 deletions rero_mef/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,15 @@ def _get_indexer_class(self, payload):
"""Get the record class from payload."""
# take the first defined doc type for finding the class
pid_type = payload.get('doc_type', 'rec')
endpoints = current_app.config.get('RECORDS_REST_ENDPOINTS')
return obj_or_import_string(
endpoints.get(pid_type).get('indexer_class', RecordIndexer))
try:
indexer = obj_or_import_string(
current_app.config[
'RECORDS_REST_ENDPOINTS'][pid_type]['indexer_class']
)
except Exception:
# provide default indexer if no indexer is defined in config.
indexer = ReroIndexer
return indexer

def process_bulk_queue(self, es_bulk_kwargs=None, stats_only=True):
"""Process bulk indexing queue.
Expand Down
Loading

0 comments on commit 6114715

Please sign in to comment.