def append_updated_record_to_queue(sender, json, record, index, doc_type):
    """Append record after an update to the queue.

    The method receives a record on before_record_index signal and
    decides if the updates made are essential to append the record
    to the queue of records to be processed by Beard.
    """
    # FIXME: Use a dedicated method when #1355 will be resolved.
    if "hep.json" in json['$schema']:
        from invenio_search import current_search_client as es
        from elasticsearch.exceptions import NotFoundError

        try:
            before_json = es.get_source(index=index,
                                        id=record.id,
                                        doc_type=doc_type)
        except (ValueError, NotFoundError):
            # The record in not available in the Elasticsearch instance.
            # This will be caught by append_new_record_to_queue method.
            return

        if _needs_beard_reprocessing(before_json['authors'], json['authors']):
            record_arguments = {'record_id': record.id}

            beard_record = DisambiguationRecord(**record_arguments)
            beard_record.save()
def append_updated_record_to_queue(sender, json, record, index, doc_type):
    """Append record after an update to the queue.

    The method receives a record on before_record_index signal and
    decides if the updates made are essential to append the record
    to the queue of records to be processed by Beard.
    """
    # FIXME: Use a dedicated method when #1355 will be resolved.
    if "hep.json" in json['$schema']:
        from invenio_search import current_search_client as es
        from elasticsearch.exceptions import NotFoundError

        try:
            before_json = es.get_source(
                index=index, id=record.id, doc_type=doc_type)
        except (ValueError, NotFoundError):
            # The record in not available in the Elasticsearch instance.
            # This will be caught by append_new_record_to_queue method.
            return

        if _needs_beard_reprocessing(before_json['authors'], json['authors']):
            record_arguments = {'record_id': record.id}

            beard_record = DisambiguationRecord(**record_arguments)
            beard_record.save()
def append_new_record_to_queue(sender, *args, **kwargs):
    """Append a new record to the queue.

    The method receives a record on after_record_insert signal and
    appends the given record UUID to the queue of records to be
    processed by Beard.
    """
    # FIXME: Use a dedicated method when #1355 will be resolved.
    if "hep.json" in sender['$schema']:
        record_arguments = {'record_id': sender.id}

        beard_record = DisambiguationRecord(**record_arguments)
        beard_record.save()
def append_new_record_to_queue(sender, *args, **kwargs):
    """Append a new record to the queue.

    The method receives a record on after_record_insert signal and
    appends the given record UUID to the queue of records to be
    processed by Beard.
    """
    # FIXME: Use a dedicated method when #1355 will be resolved.
    if "hep.json" in sender['$schema']:
        record_arguments = {'record_id': sender.id}

        beard_record = DisambiguationRecord(**record_arguments)
        beard_record.save()