@@ -256,10 +256,7 @@ def get_source_samples(neo4j_driver, uuid):
256256 are found, or None if the input UUID does not correspond to a supported
257257 entity type.
258258"""
259- def get_dataset_documents_raw (neo4j_driver , uuid , excluded_fields = None ):
260- if excluded_fields is None :
261- excluded_fields = []
262-
259+ def get_dataset_documents_raw (neo4j_driver , uuid , included_fields ):
263260 with neo4j_driver .session () as session :
264261 entity_record = session .run ("""
265262 MATCH (e:Entity {uuid: $uuid})
@@ -279,22 +276,19 @@ def get_dataset_documents_raw(neo4j_driver, uuid, excluded_fields=None):
279276 root_label = 'Upload'
280277 else :
281278 return None
282-
283- projection = "d { .* }"
284279
285- if excluded_fields :
286- null_projection = ", " .join (f"{ field } : NULL" for field in excluded_fields )
287- projection = f"d {{ .*, { null_projection } }}"
288280
289281 record = session .run ("""
290282 MATCH (root:%s {uuid: $uuid})<-[:%s]-(d:Dataset)
291- RETURN apoc.map.fromPairs(COLLECT([d.uuid, %s])) AS result
292- """ % (root_label , relationship , projection ), uuid = uuid ).single ()
283+ WITH apoc.coll.toSet(COLLECT(d)) AS datasets
284+ RETURN [d IN datasets | d { %s }] AS result
285+ """ % (root_label , relationship , ', ' .join (f'.{ f } ' for f in included_fields )),
286+ uuid = uuid ).single ()
293287
294288 if not record or not record ["result" ]:
295289 return {}
296290
297- return {uuid : dict (props ) for uuid , props in record ["result" ]. items () }
291+ return {d [ ' uuid' ] : dict (d ) for d in record ["result" ]}
298292
299293
300294
0 commit comments