Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update organizations to use id #220

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions pages/datasets/[datasetId].vue
Original file line number Diff line number Diff line change
Expand Up @@ -148,23 +148,20 @@ const getDownloadsSummary = async (config, axios) => {
}
}

const getOrganizationNames = async (algoliaIndex) => {
const getOrganizationIds = async (algoliaIndex) => {
try {
await algoliaIndex.search('', {
const { facets } = await algoliaIndex.search('', {
hitsPerPage: 0,
sortFacetValuesBy: 'alpha',
facets: 'pennsieve.organization.name',
}).then(({ facets }) => {
return facets['pennsieve.organization.name'].keys()
facets: 'pennsieve.organization.identifier',
})
return Object.keys(facets['pennsieve.organization.identifier'])
} catch (error) {
return [
'SPARC',
'SPARC Consortium',
'RE-JOIN',
'HEAL PRECISION',
"IT'IS Foundation",
"NIH PRECISION Human Pain Network"
29, //IT'IS Foundation
367, // SPARC
661, // RE-JOIN
666, // PRECISION
]
}
}
Expand Down Expand Up @@ -239,7 +236,7 @@ export default {
const datasetTypeName = typeFacet !== undefined ? typeFacet.children[0].label : 'dataset'
const store = useMainStore()
try {
let [datasetDetails, versions, downloadsSummary, sparcOrganizationNames, algoliaContributors] = await Promise.all([
let [datasetDetails, versions, downloadsSummary, sparcOrganizationIds, algoliaContributors] = await Promise.all([
getDatasetDetails(
config,
datasetId,
Expand All @@ -249,7 +246,7 @@ export default {
),
getDatasetVersions(config, datasetId, $axios),
getDownloadsSummary(config, $axios),
getOrganizationNames(algoliaIndex),
getOrganizationIds(algoliaIndex),
getContributorsFromAlgolia(algoliaIndex, datasetId)
])
const datasetDetailsContributors = algoliaContributors?.map(contributor => {
Expand Down Expand Up @@ -292,9 +289,9 @@ export default {
let originallyPublishedDate = propOr('', 'firstPublishedAt', datasetDetails)
const showTombstone = propOr(false, 'isUnpublished', datasetDetails)
// Redirect them to doi if user tries to navigate directly to a dataset ID that is not a part of SPARC
if (!sparcOrganizationNames.includes(propOr('', 'organizationName', datasetDetails)) && !isEmpty(doiLink) && !showTombstone)
if (!sparcOrganizationIds.includes(`${propOr('', 'organizationId', datasetDetails)}`) && !isEmpty(doiLink) && !showTombstone)
{
navigateTo(doiLink, { external: true, redirectCode: 301 })
await navigateTo(doiLink, { external: true, redirectCode: 301 })
}

return {
Expand Down
Loading