Skip to content

Commit

Permalink
Merge pull request #1161 from microbiomedata/fix-grow-study
Browse files Browse the repository at this point in the history
Grow Study fixes
  • Loading branch information
marySalvi authored Feb 29, 2024
2 parents d4ec9d2 + 13a4c6a commit ccd899b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
24 changes: 13 additions & 11 deletions nmdc_server/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,23 +284,25 @@ async def search_study(
children_studies = crud.search_study(db, children_condition).all()
top_level_studies = crud.search_study(db, top_level_condition).all()

# """
# If there are children studies that match the query, but the top level studies do not,
# add the parent to the top level studies
# """
for child in children_studies:
for parent_id in child.part_of:
if parent_id not in [
parent.id for parent in top_level_studies
] and child.id not in [parent.id for parent in top_level_studies]:
top_level_studies.append(child)

for parent in top_level_studies:
parent.children = []
for child in children_studies:
if child.part_of is not None and parent.id in child.part_of:
parent.children.append(child)

# If there are children studies that match the query, but their top level studies do not,
# and they are not already listed as children of another top level study,
# add the child to the top level studies
for child in children_studies:
for parent_id in child.part_of:
if (
parent_id not in [parent.id for parent in top_level_studies]
and child.id not in [parent.id for parent in top_level_studies]
and child.id
not in [child.id for parent in top_level_studies for child in parent.children]
):
top_level_studies.append(child)

count = len(top_level_studies)

total = crud.search_study(db, q.conditions).count()
Expand Down
8 changes: 8 additions & 0 deletions web/src/views/Search/SearchLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,19 @@ export default defineComponent({
.map((r) => ({
...r,
name: r.annotations.title || r.name,
children: r.children?.map((c) => ({
...c,
name: c.annotations.title || c.name,
})),
})));
const consortiumStudyResults = computed(() => Object.values(consortium.data.results.results)
.map((r) => ({
...r,
name: r.annotations.title || r.name,
children: r.children?.map((c) => ({
...c,
name: c.annotations.title || c.name,
})),
})));
const loggedInUser = computed(() => typeof stateRefs.user.value === 'string');
Expand Down

0 comments on commit ccd899b

Please sign in to comment.