Ejemplo n.º 1
0
def get_record_contents(recid):
    """
    Tries to get record from elastic search first. Failing that,
    it tries from the database.
    :param recid: Record ID to get.
    :return: a dictionary containing the record contents if the recid exists,
    None otherwise.
    """
    record = get_record(recid, doc_type=CFG_PUB_TYPE)
    if record is None:
        record = get_record_by_id(recid)

    return record
Ejemplo n.º 2
0
def get_record_contents(recid):
    """
    Tries to get record from Elasticsearch first. Failing that, it tries from the database.

    :param recid: Record ID to get.
    :return: a dictionary containing the record contents if the recid exists, None otherwise.
    """
    record = get_record(recid, doc_type=CFG_PUB_TYPE)
    if record is None:
        try:
            record = get_record_by_id(recid)
        except PIDDoesNotExistError:
            return None

    return record
Ejemplo n.º 3
0
def get_record_contents(recid, status=None):
    """
    Tries to get record from Elasticsearch first. Failing that, it tries from the database.

    :param recid: Record ID to get.
    :param status: Status of submission. If provided and not 'finished', will not check elasticsearch first.
    :return: a dictionary containing the record contents if the recid exists, None otherwise.
    """
    record = None

    if status is None or status == 'finished':
        record = get_record(recid)

    if record is None:
        try:
            record = get_record_by_id(recid)
        except PIDDoesNotExistError:
            return None

    return record
Ejemplo n.º 4
0
def test_get_record(app, load_default_data, identifiers):
    record = es_api.get_record(1)
    for key in ["inspire_id", "title"]:
        assert (record[key] == identifiers[0][key])

    assert (es_api.get_record(9999999) is None)