diff --git a/client/src/pages/openalex-affiliations/corrections.jsx b/client/src/pages/openalex-affiliations/corrections.jsx index 813b073..08845e0 100644 --- a/client/src/pages/openalex-affiliations/corrections.jsx +++ b/client/src/pages/openalex-affiliations/corrections.jsx @@ -15,18 +15,19 @@ export default function Corrections() { const [chartOptionsDomains, setChartOptionsDomains] = useState({}); const [chartOptionsDates, setChartOptionsDates] = useState({}); const [corrections, setCorrections] = useState([]); + const [numberOfCorrections, setNumberOfCorrections] = useState(0); const getCorrections = async (state, page = 0) => { const offset = page * ODS_BY_PAGE; let _corrections = []; const url = `${ODS_URL}/records?order_by=github_issue_id&limit=${ODS_BY_PAGE}&offset=${offset}&refine=state%3A${state}`; - const { results } = await (await fetch(url)).json(); + const { results, total_count: totalCount } = await (await fetch(url)).json(); _corrections = _corrections.concat(results); // if (results.length === ODS_BY_PAGE) { // const c = await getCorrections(state, page + 1); // _corrections = _corrections.concat(c); // } - return _corrections; + return { corrections: _corrections, totalCount }; }; const getFacetDomains = async () => { @@ -75,7 +76,8 @@ export default function Corrections() { }, []); const queries = [getCorrections('closed'), getCorrections('open')]; const [closedCorrections, openedCorrections] = await Promise.all(queries); - const correctionsTmp = [...closedCorrections, ...openedCorrections]; + const correctionsTmp = [...closedCorrections.corrections, ...openedCorrections.corrections]; + setNumberOfCorrections(closedCorrections.totalCount + openedCorrections.totalCount); correctionsTmp.reverse((a, b) => b.date_opened - a.date_opened); setCorrections(correctionsTmp); // let data = {}; @@ -155,12 +157,12 @@ export default function Corrections() { {!isFetching && isFetched && corrections && (