Skip to content

Commit

Permalink
refactor(openalex): Remove unused utils
Browse files Browse the repository at this point in the history
  • Loading branch information
annelhote committed Dec 10, 2024
1 parent db9b4d4 commit d671ca5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
11 changes: 1 addition & 10 deletions client/src/pages/openalex-affiliations/results/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { useLocation, useNavigate, useSearchParams } from 'react-router-dom';
import { status } from '../../../config';
import useToast from '../../../hooks/useToast';
import Header from '../../../layout/header';
import { getAffiliationsCorrections } from '../../../utils/curations';
import getFlagEmoji from '../../../utils/flags';
import { getRorData, isRor } from '../../../utils/ror';
import { normalize, removeDiacritics } from '../../../utils/strings';
Expand All @@ -42,7 +41,6 @@ export default function Affiliations() {

const [addList, setAddList] = useState([]);
const [affiliations, setAffiliations] = useState([]);
const [allOpenalexCorrections, setAllOpenalexCorrections] = useState([]); // TODO: ??
const [body, setBody] = useState({});
const [cleanRor, setCleanRor] = useState('');
const [filteredAffiliationName, setFilteredAffiliationName] = useState('');
Expand Down Expand Up @@ -177,16 +175,9 @@ export default function Affiliations() {
`${affiliation.key.replace('[ source: ', '').replace(' ]', '')} ${affiliation.rors.map((_ror) => _ror.rorId).join(' ')}`,
),
);
// Recompute corrections only when the array has changed
if (filteredAffiliationsTmp.length !== filteredAffiliations.length) {
setAllOpenalexCorrections([
...allOpenalexCorrections,
...getAffiliationsCorrections(filteredAffiliationsTmp),
]);
}
setFilteredAffiliations(filteredAffiliationsTmp);
setIsLoading(false);
}, [affiliations, allOpenalexCorrections, filteredAffiliationName, filteredAffiliations.length, filteredStatus]);
}, [affiliations, filteredAffiliationName]);

useEffect(() => {
if (ror === '') {
Expand Down
12 changes: 1 addition & 11 deletions client/src/utils/curations.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
const getAffiliationsCorrections = (affiliations) => affiliations
.filter((affiliation) => affiliation.hasCorrection)
.map((affiliation) => ({
id: affiliation.id,
rawAffiliationString: affiliation.name,
rorsInOpenAlex: affiliation.rors,
worksExample: affiliation.worksExample,
worksOpenAlex: affiliation.worksOpenAlex,
}));

const getMentionsCorrections = (mentions) => mentions
.filter((mention) => mention.hasCorrection)
.map((mention) => {
Expand Down Expand Up @@ -61,4 +51,4 @@ const getMentionsCorrections = (mentions) => mentions
})
.flat();

export { getAffiliationsCorrections, getMentionsCorrections };
export { getMentionsCorrections };

0 comments on commit d671ca5

Please sign in to comment.