def process_references_in_records(uuids): references_to_reindex = [] try: for uuid in uuids: try: record = InspireRecord.get_record(uuid) if isinstance(record, LiteratureRecord): references = record.get_modified_references() references.extend( record.get_newest_linked_conferences_uuid()) references.extend(record.get_modified_institutions_uuids()) LOGGER.info( f"Reindexing {len(references)} references", recid=record["control_number"], uuid=uuid, ) references_to_reindex.extend(references) except Exception: LOGGER.exception( "Cannot process references on index_records task.", uuid=uuid) if references_to_reindex: batch_index(references_to_reindex) except Exception: LOGGER.exception("Cannot reindex references") return uuids
def index_records(uuids): """Task which Indexes specified records in ElasticSearch Args: recids: records to index Returns: set: set of processed records uuids """ try: batch_index(uuids) except Exception: LOGGER.exception("Error during batch index") return uuids
def process_references_in_records(uuids): references_to_reindex = set() try: for uuid in uuids: try: record = InspireRecord.get_record(uuid, with_deleted=True) references = get_references_to_update(record) references_to_reindex.update(references) except Exception: LOGGER.exception( "Cannot process references on index_records task.", uuid=uuid) if references_to_reindex: batch_index(list(references_to_reindex)) LOGGER.info("processing uuids", uuids=references_to_reindex) except Exception: LOGGER.exception("Cannot reindex references") return uuids