Skip to content

Commit

Permalink
Merge pull request #1194 from girder/aggregation-change
Browse files Browse the repository at this point in the history
Another refactor of the which-folders-have-annotations pipeline
  • Loading branch information
manthey authored Jun 7, 2023
2 parents 5f30586 + 7bbb26b commit 9408b52
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Changes
- Change how extensions and fallback priorities interact ([#1192](../../pull/1192))
- Refactor reading the .large_image_config.yaml file on the girder client ([#1193](../../pull/1193))
- Refactor of the which-folders-have-annotations pipeline ([#1194](../../pull/1194))

## 1.22.2

Expand Down
29 changes: 14 additions & 15 deletions girder_annotation/girder_large_image_annotation/rest/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,25 +601,24 @@ def getFolderAnnotations(self, id, recurse, user, limit=False, offset=False, sor
] if not user['admin'] else []
recursivePipeline = [
{'$match': {'_id': ObjectId(id)}},
{'$facet': {
'documents1': [{'$match': {'_id': ObjectId(id)}}],
'documents2': [
{'$graphLookup': {
'from': 'folder',
'startWith': '$_id',
'connectFromField': '_id',
'connectToField': 'parentId',
'as': '__children'
}},
{'$unwind': {'path': '$__children'}},
{'$replaceRoot': {'newRoot': '$__children'}}
]
{'$graphLookup': {
'from': 'folder',
'startWith': ObjectId(id),
'connectFromField': '_id',
'connectToField': 'parentId',
'as': '__children',
}},
{'$lookup': {
'from': 'folder',
'localField': '_id',
'foreignField': '_id',
'as': '__self',
}},
{'$project': {'__children': {'$concatArrays': [
'$documents1', '$documents2'
'$__self', '$__children'
]}}},
{'$unwind': {'path': '$__children'}},
{'$replaceRoot': {'newRoot': '$__children'}}
{'$replaceRoot': {'newRoot': '$__children'}},
] if recurse else [{'$match': {'_id': ObjectId(id)}}]

# We are only finding anntoations that we can change the permissions
Expand Down

0 comments on commit 9408b52

Please sign in to comment.