diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index 26d5efc5..9f88d076 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -70,7 +70,7 @@ jobs: config_file: .github/config/changelog.js - name: 📦 Create release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: diff --git a/client/src/components/button-dropdown/index.jsx b/client/src/components/button-dropdown/index.jsx index aa474a15..209d0829 100644 --- a/client/src/components/button-dropdown/index.jsx +++ b/client/src/components/button-dropdown/index.jsx @@ -34,7 +34,7 @@ export default function ButtonDropdown({ className, data, label, searchParams }) icon="save-line" size="sm" > - {`Export ${label}`} + {`Export ${label} (${data.length})`}
+ + ); const { toast } = useToast(); @@ -50,19 +67,12 @@ export default function OpenalexView({ }); if (isValid) { data.rorsToCorrect = newValue; - data.hasCorrection = true; - const newCorrections = []; - allAffiliations - .filter((aff) => aff.hasCorrection) - .forEach((aff) => { - const correction = { - rawAffiliationString: aff.name, - rorsInOpenAlex: aff.rors, - correctedRors: aff.rorsToCorrect, - worksExample: aff.worksExample, - }; - newCorrections.push(correction); - }); + if (data.rors.map((r) => r.rorId).join(';') !== newValue) { + data.hasCorrection = true; + } else { + data.hasCorrection = false; + } + const newCorrections = getCorrections(allAffiliations); setAllOpenalexCorrections(newCorrections); } } @@ -111,7 +121,7 @@ export default function OpenalexView({ paginatorLeft={paginatorLeft} paginatorPosition="top bottom" paginatorTemplate="RowsPerPageDropdown FirstPageLink PrevPageLink CurrentPageReport NextPageLink LastPageLink" - rows={100} + rows={50} rowsPerPageOptions={[50, 100, 200, 500]} scrollable selectionPageOnly={selectionPageOnly} @@ -131,39 +141,38 @@ export default function OpenalexView({ /> cellEditor(options)} /> - diff --git a/client/src/pages/views/openalex.jsx b/client/src/pages/views/openalex.jsx index 8445cd99..34cb4c20 100644 --- a/client/src/pages/views/openalex.jsx +++ b/client/src/pages/views/openalex.jsx @@ -61,14 +61,15 @@ Openalex.propTypes = { works: PropTypes.arrayOf(PropTypes.string).isRequired, worksNumber: PropTypes.number.isRequired, })).isRequired, - allOpenalexCorrections: PropTypes.arrayOf(PropTypes.shape({ - affiliations: PropTypes.arrayOf(PropTypes.object), - allIds: PropTypes.arrayOf(PropTypes.object).isRequired, - datasource: PropTypes.arrayOf(PropTypes.string).isRequired, - id: PropTypes.string.isRequired, - status: PropTypes.string.isRequired, - type: PropTypes.string.isRequired, - }).isRequired).isRequired, + allOpenalexCorrections: PropTypes.arrayOf( + PropTypes.shape({ + rawAffiliationString: PropTypes.string.isRequired, + rorsInOpenAlex: PropTypes.arrayOf(PropTypes.object).isRequired, + correctedRors: PropTypes.string.isRequired, + worksExample: PropTypes.arrayOf(PropTypes.object).isRequired, + worksOpenAlex: PropTypes.arrayOf(PropTypes.string).isRequired, + }), + ).isRequired, setAllOpenalexCorrections: PropTypes.func.isRequired, options: PropTypes.object.isRequired, }; diff --git a/client/src/utils/openalex.jsx b/client/src/utils/openalex.jsx new file mode 100644 index 00000000..9a86defa --- /dev/null +++ b/client/src/utils/openalex.jsx @@ -0,0 +1,20 @@ +const getCorrections = (affiliations) => { + const newCorrections = []; + affiliations + .filter((aff) => aff.hasCorrection) + .forEach((aff) => { + const correction = { + rawAffiliationString: aff.name, + rorsInOpenAlex: aff.rors, + correctedRors: aff.rorsToCorrect, + worksExample: aff.worksExample, + worksOpenAlex: aff.worksOpenAlex, + }; + newCorrections.push(correction); + }); + return newCorrections; +}; + +export { + getCorrections, +}; diff --git a/client/src/utils/templates.jsx b/client/src/utils/templates.jsx index e636ddd1..838e9bca 100644 --- a/client/src/utils/templates.jsx +++ b/client/src/utils/templates.jsx @@ -39,9 +39,13 @@ const statusRowFilterTemplate = (options) => ( const getIdsTemplate = (ids) => { let html = '
    '; ids.forEach((id) => { - html += `
  • ${id.id_type}: `; + html += `
  • `; const idLink = getIdLink(id.id_type, id.id_value); - html += idLink ? `${id.id_value}` : `${id.id_value}`; + let idValueDisplay = ''; + if (id.id_value.length > 18) { + idValueDisplay = id.id_value.slice(0, 18).concat('..'); + } + html += idLink ? `${idValueDisplay}` : `${id.id_value}`; html += '
  • '; }); html += '
'; @@ -118,16 +122,18 @@ const datasourceTemplate = (rowData) => { const correctionTemplate = (rowData) => { let html = ''; + html = html.concat('
    '); const rorsToCorrect = rowData.rorsToCorrect.split(';').map((item) => item.trim()).filter((item) => item.length > 0); if (rorsToCorrect.length > 0) { - html = html.concat('
      '); rorsToCorrect.forEach((ror) => { html = html.concat(`
    • ${ror}
    • `); }); - html = html.concat('
    '); - if (rowData.hasCorrection) { - html = `${ html }`; - } + } else { + html = html.concat('
  • '); + } + html = html.concat('
'); + if (rowData.hasCorrection) { + html = `${ html }`; } return ; }; @@ -136,8 +142,17 @@ const nameTemplate = (rowData) => {status[rowData?.status ?? rowData]?.label}; +const resetCorrection = (rowData, allAffiliations) => { + console.log('ttt', rowData); + const row = { rowData }; + row.rowData.hasCorrection = false; + row.rowData.rorsToCorrect = rowData.rors.map((e) => e.rorId).join(';'); +}; + const hasCorrectionTemplate = (rowData) => (rowData?.hasCorrection - ? {correction.corrected.label} + ? ( + {correction.corrected.label} + ) : ''); export { diff --git a/server/src/routes/github.routes.js b/server/src/routes/github.routes.js index 189c0489..348dc148 100644 --- a/server/src/routes/github.routes.js +++ b/server/src/routes/github.routes.js @@ -24,7 +24,10 @@ const createIssue = (issue, email) => { body += `new_rors: ${issue.correctedRors}\n`; const previousRoRs = issue.rorsInOpenAlex.map((e) => e.rorId).join(';'); body += `previous_rors: ${previousRoRs}\n`; - const workIds = issue.worksExample.filter((e) => e.id_type === 'openalex').map((e) => e.id_value).join(';'); + let workIds = issue.worksExample.filter((e) => e.id_type === 'openalex').map((e) => e.id_value).join(';'); + if (issue.worksOpenAlex) { + workIds = issue.worksOpenAlex.join(';'); + } body += `works_examples: ${workIds}\n`; body += `contact: ${encrypt(email.split('@')[0])} @ ${email.split('@')[1]}\n`; octokit.rest.issues.create({ diff --git a/server/src/routes/works.routes.js b/server/src/routes/works.routes.js index f0f1dc56..d01bf7a0 100644 --- a/server/src/routes/works.routes.js +++ b/server/src/routes/works.routes.js @@ -7,6 +7,7 @@ import { chunkArray, countUniqueValues, range } from '../utils/utils'; import { datasetsType, deduplicateWorks, getFosmWorks, getOpenAlexPublications, groupByAffiliations } from '../utils/works'; const SEED_MAX = 2048; +const USE_CACHE = true; const router = new express.Router(); @@ -48,7 +49,10 @@ const getData = async ({ options, resetCache = false }) => { const searchId = shasum.digest('hex'); const queryId = Math.floor(Math.random() * SEED_MAX); console.time(`0. Query ${queryId} | Retrieve cache if exists ${options.affiliationStrings}`); - const cache = await getCache({ searchId }); + let cache = false; + if (USE_CACHE) { + cache = await getCache({ searchId }); + } console.timeEnd(`0. Query ${queryId} | Retrieve cache if exists ${options.affiliationStrings}`); if (cache && !resetCache) { const extractionDate = new Date(cache.extractionDate); diff --git a/server/src/utils/works.js b/server/src/utils/works.js index 5a04d73a..f9c2b196 100644 --- a/server/src/utils/works.js +++ b/server/src/utils/works.js @@ -467,7 +467,7 @@ const groupByAffiliations = ({ options, works }) => { if (toKeep[normalizedAffiliation]?.keepAffiliation) { if (deduplicatedAffiliations?.[normalizedAffiliation]) { deduplicatedAffiliations[normalizedAffiliation].works.push(id); - if (deduplicatedAffiliations[normalizedAffiliation].worksExample.length < 10) { + if (deduplicatedAffiliations[normalizedAffiliation].worksExample.length < 999) { deduplicatedAffiliations[normalizedAffiliation].worksExample.push(work.allIds); } } else { @@ -478,6 +478,7 @@ const groupByAffiliations = ({ options, works }) => { name: affiliation.rawAffiliation, nameHtml: toKeep[normalizedAffiliation].displayAffiliation, rors: affiliation.rors || [], + rorsNumber: affiliation.rors?.length || 0, rorsToCorrect: (affiliation.rorsToCorrect || []).join(';'), source: affiliation.source, status: 'tobedecided', @@ -498,8 +499,9 @@ const groupByAffiliations = ({ options, works }) => { ...affiliation, id: index.toString(), works: uniqueWorks, - worksExample: uniqueWorksExample, + worksExample: uniqueWorksExample.slice(0, 10), worksNumber: uniqueWorks.length, + worksOpenAlex: uniqueWorksExample.filter((w) => w.id_type === 'openalex').map((w) => w.id_value || 0).filter((w) => w !== 0), }); }); return allAffiliationsTmp;