Skip to content

Commit

Permalink
fix(datasets): Filter datasets on "genre:dataset" to filter files
Browse files Browse the repository at this point in the history
  • Loading branch information
annelhote committed Nov 17, 2023
1 parent b5f8570 commit bc71dcb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions client/src/pages/home/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export default function Home() {
let allPublicationsTmp = [];
if (data) {
allDatasetsTmp = data.datasets
.filter((dataset) => !!dataset?.affiliations)
.map((dataset) => ({
...dataset,
affiliationsHtml: getAffiliationsHtmlField(dataset, regexp),
Expand Down
2 changes: 1 addition & 1 deletion server/src/routes/works.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ router.route('/works')
const results = await Promise.all([
getBsoWorks({ options, index: process.env.VITE_BSO_PUBLICATIONS_INDEX }),
getOpenAlexPublications(options),
getBsoWorks({ options, index: process.env.VITE_BSO_DATASETS_INDEX }),
getBsoWorks({ options, index: process.env.VITE_BSO_DATASETS_INDEX, filter: 'q=genre:dataset' }),
]);
const data = { datasets: [], publications: [], total: {} };
results.slice(0, 2).forEach((publication) => {
Expand Down
12 changes: 9 additions & 3 deletions server/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ const getBsoCount = async (options) => {
return 'Oops... BSO API request did not work';
};

const getBsoWorks = async ({ allResults = [], index = process.env.VITE_BSO_PUBLICATIONS_INDEX, options, pit, searchAfter }) => {
const getBsoWorks = async ({
allResults = [], filter, index = process.env.VITE_BSO_PUBLICATIONS_INDEX, options, pit, searchAfter,
}) => {
if (!pit) {
const response = await fetch(
`${process.env.VITE_BSO_URL}/${index}/_pit?keep_alive=${process.env.VITE_BSO_PIT_KEEP_ALIVE}`,
Expand All @@ -69,7 +71,11 @@ const getBsoWorks = async ({ allResults = [], index = process.env.VITE_BSO_PUBLI
Authorization: process.env.VITE_BSO_AUTH,
},
};
return fetch(`${process.env.VITE_BSO_URL}/_search`, params)
let url = `${process.env.VITE_BSO_URL}/_search`;
if (filter) {
url += `?${filter}`;
}
return fetch(url, params)
.then((response) => {
if (response.ok) return response.json();
return 'Oops... BSO API request did not work';
Expand All @@ -90,7 +96,7 @@ const getBsoWorks = async ({ allResults = [], index = process.env.VITE_BSO_PUBLI
if (hits.length > 0 && (Number(process.env.VITE_BSO_MAX_SIZE) === 0 || allResults.length < Number(process.env.VITE_BSO_MAX_SIZE))) {
// eslint-disable-next-line no-param-reassign
searchAfter = hits.at('-1').sort;
return getBsoWorks({ allResults, index, options, pit, searchAfter });
return getBsoWorks({ allResults, filter, index, options, pit, searchAfter });
}
if (pit) {
fetch(
Expand Down

0 comments on commit bc71dcb

Please sign in to comment.