Skip to content

Commit

Permalink
feat: add my institution data library
Browse files Browse the repository at this point in the history
  • Loading branch information
fboulnois committed Sep 28, 2023
1 parent 92b7a91 commit e00e8b0
Showing 1 changed file with 40 additions and 5 deletions.
45 changes: 40 additions & 5 deletions src/pages/DatasetSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,45 @@ import mgbIcon from '../images/mass-general-brigham-logo.svg';
import elwaziIcon from '../images/elwazi-logo-color.svg';
import { Storage } from '../libs/storage';

const signingOfficialQuery = (user) => {
return {
'match_phrase': {
'submitter.institution.id': user.institution.id
}
};
}

// query to return studies from the user's institution that are approved by the DAC and open access studies
const myInstitutionQuery = (user) => {
return {
'bool': {
'should': [
{
'bool': {
'must': [
{
'match_phrase': {
'submitter.institution.id': user.institution.id
}
},
{
'term': {
'dacApproval': true
}
}
]
}
},
{
'term': {
'openAccess': true
}
}
],
}
};
}

export const DatasetSearch = (props) => {
const { location } = props;
const [datasets, setDatasets] = useState([]);
Expand Down Expand Up @@ -70,11 +109,7 @@ export const DatasetSearch = (props) => {
title: 'eLwazi Data Library',
},
'/datalibrary_myinstitution': {
query: {
'match_phrase': {
'submitter.institution.id': user.isSigningOfficial ? user.institution.id : null
}
},
query: user.isSigningOfficial ? signingOfficialQuery(user) : myInstitutionQuery(user),
icon: null,
title: user.institution.name + ' Data Library',
},
Expand Down

0 comments on commit e00e8b0

Please sign in to comment.