Skip to content

Commit

Permalink
fix annotation loading attempt #1
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkent committed Nov 21, 2023
1 parent 7fd89e6 commit 19fdd76
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
20 changes: 13 additions & 7 deletions store/neurostore/resources/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,13 @@ def update_or_create(cls, data, id=None, user=None, record=None, commit=True):
q = LnCls._model.query.filter_by(**query_args)
if LnCls._model is Annotation:
q = q.options(
joinedload(
Annotation.annotation_analyses).options(
joinedload(AnnotationAnalysis.analysis),
joinedload(AnnotationAnalysis.studyset_study)))
joinedload(Annotation.annotation_analyses).options(
joinedload(AnnotationAnalysis.analysis),
joinedload(AnnotationAnalysis.studyset_study).options(
joinedload(StudysetStudy.study)
)
)
)
v = q.first()
if v is None:
abort(400)
Expand Down Expand Up @@ -345,10 +348,13 @@ def get(self, id):
q = q.options(nested_load(self))
if self._model is Annotation:
q = q.options(
joinedload(
Annotation.annotation_analyses).options(
joinedload(Annotation.annotation_analyses).options(
joinedload(AnnotationAnalysis.analysis),
joinedload(AnnotationAnalysis.studyset_study)))
joinedload(AnnotationAnalysis.studyset_study).options(
joinedload(StudysetStudy.study)
)
)
)
record = q.filter_by(id=id).first_or_404()
if self._model is Studyset and args["nested"]:
snapshot = StudysetSnapshot()
Expand Down
13 changes: 8 additions & 5 deletions store/neurostore/resources/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,15 @@ class AnnotationsView(ObjectView, ListView):

def after_update_or_create(self, record):
q = Annotation.query.filter_by(id=record.id)
q = q.options(nested_load(self, include_linked=True))
q = q.options(nested_load(self))
q = q.options(
joinedload(
Annotation.annotation_analyses).options(
joinedload(AnnotationAnalysis.analysis),
joinedload(AnnotationAnalysis.studyset_study)))
joinedload(Annotation.annotation_analyses).options(
joinedload(AnnotationAnalysis.analysis),
joinedload(AnnotationAnalysis.studyset_study).options(
joinedload(StudysetStudy.study)
)
)
)
return q.first()

def view_search(self, q, args):
Expand Down

0 comments on commit 19fdd76

Please sign in to comment.