Skip to content

Commit

Permalink
feat(api): Optimize the querying of FOSM
Browse files Browse the repository at this point in the history
  • Loading branch information
annelhote committed Nov 21, 2023
1 parent ca01a78 commit 0f5bdf5
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions server/src/routes/works.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,19 @@ router.route('/works')
res.status(400).json({ message: 'You must provide at least one affiliation.' });
} else {
const results = await Promise.all([
getBsoWorks({ options, index: process.env.VITE_BSO_PUBLICATIONS_INDEX, filter: 'q=-genre_raw:dataset' }),
getBsoWorks({ options, index: process.env.VITE_BSO_PUBLICATIONS_INDEX }),
getOpenAlexPublications(options),
getBsoWorks({ options, index: process.env.VITE_BSO_DATASETS_INDEX, filter: 'q=genre:dataset' }),
getBsoWorks({ options, index: process.env.VITE_BSO_PUBLICATIONS_INDEX, filter: 'q=genre_raw:dataset' }),
]);
const data = {};
data.publications = [...results[0].results, ...results[1].results];
data.datasets = [...results[2].results, ...results[3].results];
data.publications = [
...results[0].results.filter((result) => result.genre_raw !== 'dataset'),
...results[1].results,
];
data.datasets = [
...results[0].results.filter((result) => result.genre_raw === 'dataset'),
...results[2].results,
];
// Deduplicate publications by DOI or by hal_id
const deduplicatedPublications = {};
data.publications.forEach((publication) => {
Expand Down

0 comments on commit 0f5bdf5

Please sign in to comment.