Skip to content

Commit

Permalink
fix(openalex): Restore excluded RORs
Browse files Browse the repository at this point in the history
  • Loading branch information
annelhote committed Dec 4, 2024
1 parent 8ad0708 commit 728a575
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 16 deletions.
4 changes: 1 addition & 3 deletions client/src/pages/affiliationsTab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ export default function AffiliationsTab({ affiliations, selectedAffiliations, se
}, [affiliations]);

useEffect(() => {
if (timer) {
clearTimeout(timer);
}
if (timer) clearTimeout(timer);
const timerTmp = setTimeout(() => {
const filteredAffiliationsTmp = affiliations.filter((affiliation) => {
const regex = new RegExp(removeDiacritics(filteredAffiliationName));
Expand Down
25 changes: 24 additions & 1 deletion client/src/pages/openalex-affiliations/results/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export default function Affiliations() {
const getData = async () => {
const queryParams = {
endYear: searchParams.get('endYear') ?? '2023',
excludedRors: searchParams.get('excludedRors') ?? '',
getRorChildren: searchParams.get('getRorChildren') ?? '0',
startYear: searchParams.get('startYear') ?? '2023',
};
Expand Down Expand Up @@ -189,6 +190,8 @@ export default function Affiliations() {
setFilteredAffiliations(filteredAffiliationsTmp);
}, 500);
setTimer(timerTmp);
// The timer should not be tracked
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [affiliations, allOpenalexCorrections, filteredAffiliationName, filteredAffiliations.length, filteredStatus]);

useEffect(() => {
Expand Down Expand Up @@ -465,8 +468,28 @@ export default function Affiliations() {
</div>
</Col>
</Row>
<Row>
<Col>
<div className="wm-title">
<span>
<i className="ri-prohibited-line fr-mr-1w" />
Excluded RORs
</span>
</div>
<div className="wm-content">
{body.excludedRors.split(' ').map((excludedRor) => (
<Tag
className="fr-mr-1w"
color="green-archipel"
key="openalex-affiliations-rors-excluded"
>
{excludedRor}
</Tag>
))}
</div>
</Col>
</Row>
</div>

</Col>
<Col md={10}>
<div
Expand Down
24 changes: 12 additions & 12 deletions client/src/pages/openalex-affiliations/search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function OpenalexAffiliationsSearch() {
const [message, setMessage] = useState('');
const [messageType, setMessageType] = useState('');
const [onInputAffiliationsHandler, setOnInputAffiliationsHandler] = useState(false);
const [rorExclusions, setRorExclusions] = useState('');
const [excludedRors, setExcludedRors] = useState('');
const [searchedAffiliations, setSearchedAffiliations] = useState([]);
const [tags, setTags] = useState([]);

Expand Down Expand Up @@ -64,6 +64,7 @@ export default function OpenalexAffiliationsSearch() {
getRorChildren: searchParams.get('getRorChildren') ?? '0',
startYear: searchParams.get('startYear') ?? '2023',
});
setExcludedRors(currentSearchParams.excludedRors);
const newSearchedAffiliations = affiliations.filter(
(affiliation) => !searchedAffiliations.includes(affiliation),
);
Expand All @@ -81,12 +82,7 @@ export default function OpenalexAffiliationsSearch() {
}
setIsLoading(false);
}
}, [
deletedAffiliations,
searchedAffiliations,
searchParams,
setSearchParams,
]);
}, [deletedAffiliations, searchedAffiliations, searchParams, setSearchParams, currentSearchParams.excludedRors]);

useEffect(() => {
const getData = async () => {
Expand Down Expand Up @@ -196,7 +192,9 @@ export default function OpenalexAffiliationsSearch() {
}
setMessageType('');
setMessage('');
navigate(`/openalex-affiliations/results${search}`);
const _searchParams = new URLSearchParams(search);
_searchParams.set('excludedRors', excludedRors);
navigate(`/openalex-affiliations/results?${_searchParams.toString()}`);
};

const switchGetRorChildren = () => setSearchParams({ ...currentSearchParams, getRorChildren: currentSearchParams.getRorChildren === '1' ? '0' : '1' });
Expand Down Expand Up @@ -288,8 +286,8 @@ export default function OpenalexAffiliationsSearch() {
<TextInput
hint="You can focus on recall issues in OpenAlex (missing ROR). This way, only affiliation strings that are NOT matched in OpenAlex to this specific ROR will be retrieved. If several ROR to exclude, separate them by space."
label="ROR to exclude: exclude affiliation strings already mapped to a specific ROR in OpenAlex"
onChange={(e) => setRorExclusions(e.target.value)}
value={rorExclusions}
onChange={(e) => setExcludedRors(e.target.value)}
value={excludedRors}
/>
</Col>
<Col xs="12">
Expand Down Expand Up @@ -374,8 +372,10 @@ export default function OpenalexAffiliationsSearch() {
<TextInput
hint="You can focus on recall issues in OpenAlex (missing ROR). This way, only affiliation strings that are NOT matched in OpenAlex to this specific ROR will be retrieved. If several ROR to exclude, separate them by space."
label="ROR to exclude: exclude affiliation strings already mapped to a specific ROR in OpenAlex"
onChange={(e) => setRorExclusions(e.target.value)}
value={rorExclusions}
onChange={(e) => {
setExcludedRors(e.target.value);
}}
value={excludedRors}
/>
</Col>
<Col offsetXs="1" className="text-right fr-pl-3w">
Expand Down

0 comments on commit 728a575

Please sign in to comment.