Skip to content
Snippets Groups Projects
Commit 9b4e1bc3 authored by Megan Henning's avatar Megan Henning
Browse files

Add new indexing of parent

parent 638629cd
No related branches found
No related tags found
No related merge requests found
......@@ -296,7 +296,7 @@ def remove_blacklisted_keys(obj):
for key in BLACKLIST_KEYS:
obj.pop(key, None)
def handle_files(parent, files, dicom_mappings, permissions, doc):
def handle_files(parent, parent_type, files, dicom_mappings, permissions, doc):
doc['container_type'] = 'file'
for f in files:
# f.pop('info', None)
......@@ -344,6 +344,11 @@ def handle_files(parent, files, dicom_mappings, permissions, doc):
generated_id = str(parent['_id']) + '_' + f['name']
doc['parent'] = {
'_id': parent['_id'],
'type': parent_type
}
doc_s = json.dumps(doc, default=encoder.custom_json_serializer)
try:
# es.index(index=DE_INDEX, id=generated_id, parent=str(parent['_id']), doc_type='file', body=doc)
......@@ -420,7 +425,7 @@ if __name__ == '__main__':
doc_s = json.dumps(doc, default=encoder.custom_json_serializer)
es.index(index=DE_INDEX, id=str(p['_id']), doc_type='flywheel', body=doc_s)
handle_files(p, files, dicom_mappings, permissions, doc)
handle_files(p, 'project', files, dicom_mappings, permissions, doc)
sessions = db.sessions.find({'project': p['_id']})
......@@ -444,7 +449,7 @@ if __name__ == '__main__':
doc_s = json.dumps(doc, default=encoder.custom_json_serializer)
es.index(index=DE_INDEX, id=str(s['_id']), doc_type='flywheel', body=doc_s)
handle_files(s, files, dicom_mappings, permissions, doc)
handle_files(s, 'session', files, dicom_mappings, permissions, doc)
for an in analyses:
files = an.pop('files', [])
......@@ -464,7 +469,7 @@ if __name__ == '__main__':
files = [f for f in files if f.get('output')]
handle_files(an, files, dicom_mappings, permissions, doc)
handle_files(an, 'analysis', files, dicom_mappings, permissions, doc)
......@@ -489,7 +494,7 @@ if __name__ == '__main__':
es.index(index=DE_INDEX, id=str(a['_id']), doc_type='flywheel', body=doc_s)
handle_files(a, files, dicom_mappings, permissions, doc)
handle_files(a, 'acquisition', files, dicom_mappings, permissions, doc)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment