diff --git a/src/app_neo4j_queries.py b/src/app_neo4j_queries.py index 8fc130b0..2975c908 100644 --- a/src/app_neo4j_queries.py +++ b/src/app_neo4j_queries.py @@ -1198,19 +1198,12 @@ def get_entities_by_uuid(neo4j_driver, """ def get_batch_ids(neo4j_driver, id_list): query = """ - MATCH (e) - WHERE e.uuid IN $id_list OR e.hubmap_id IN $id_list - WITH e, [id IN $id_list WHERE id = e.uuid OR id = e.hubmap_id][0] AS original_id - RETURN original_id, e.uuid AS uuid, e.hubmap_id AS hubmap_id + MATCH (e:Entity) + WHERE e.uuid IN $id_list + RETURN apoc.map.fromPairs(COLLECT([e.uuid, e.hubmap_id])) AS result """ - result_map = {} - with neo4j_driver.session() as session: - result = session.run(query, id_list=id_list) - for record in result: - result_map[record['original_id']] = { - "uuid": record['uuid'], - "hubmap_id": record['hubmap_id'] - } - return result_map \ No newline at end of file + record = session.run(query, id_list=id_list) + raw = record.single()["result"] + return {uuid: {"uuid": uuid, "hubmap_id": hubmap_id} for uuid, hubmap_id in raw.items()}