-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better OpenAlex support #1316
Better OpenAlex support #1316
Conversation
092901d
to
c72db4b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
I left few suggestions.
@@ -49,10 +49,14 @@ export default function MentionsOverview() { | |||
|
|||
const searchTypeTerm: SearchTermInfo = extractSearchTerm(sanitisedSearch) | |||
const termEscaped = encodeURIComponent(sanitisedSearch) | |||
if (searchTypeTerm.type === 'doi') { | |||
return `doi=eq.${termEscaped}` | |||
switch (searchTypeTerm.type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use default
instead of title?
{isAdmin && | ||
<> | ||
<ControlledTextField | ||
control={control} | ||
options={{ | ||
name: 'doi', | ||
label: config.doi.label, | ||
useNull: true, | ||
defaultValue: formData?.doi, | ||
helperTextMessage: config.doi.help, | ||
helperTextCnt: `${formData?.doi?.length || 0}/${config.doi.validation.maxLength.value}`, | ||
}} | ||
rules={config.doi.validation} | ||
/> | ||
<div className="py-2"></div> | ||
</> | ||
<> | ||
<ControlledTextField | ||
control={control} | ||
options={{ | ||
name: 'doi', | ||
label: config.doi.label, | ||
useNull: true, | ||
defaultValue: formData?.doi, | ||
helperTextMessage: config.doi.help, | ||
helperTextCnt: `${formData?.doi?.length || 0}/${config.doi.validation.maxLength.value}`, | ||
}} | ||
rules={config.doi.validation} | ||
/> | ||
<div className="py-2"></div> | ||
<ControlledTextField | ||
control={control} | ||
options={{ | ||
name: 'openalex_id', | ||
label: config.openalex_id.label, | ||
useNull: true, | ||
defaultValue: formData?.openalex_id, | ||
helperTextMessage: config.openalex_id.help, | ||
}} | ||
rules={config.openalex_id.validation} | ||
/> | ||
<div className="py-2"></div> | ||
</> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two points:
- DOI / OpenAlex look different (DOI does not have help and have char count). Can we use same approach with OpenAlexId input?
- I think is better to have these ID's at the bottom. This modal is used for manual adding of mentions. The main assumption is that these do not have DOI or OpenAlexID (otherwise you can add them automatically using search).
We search in <strong> <a href="https://crossref.org" target="_blank">Crossref</a>, <a href="https://datacite.org" target="_blank">DataCite</a></strong> and the RSD. | ||
We search in <strong> <a href="https://www.crossref.org/" target="_blank">Crossref</a>, <a href="https://datacite.org" target="_blank">DataCite</a>, <a href="https://openalex.org/" target="_blank">OpenAlex</a></strong> and the RSD. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both work with or without www
.
@@ -39,35 +40,57 @@ export default function FindMentionSection({id,config,findPublicationByTitle}:Fi | |||
const {session: {token}} = useAuth() | |||
const {onAdd} = useEditMentionReducer() | |||
|
|||
async function findPublication(searchFor: string) { | |||
async function findPublication(searchFor: string): Promise<MentionItemProps[]> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer return type to be inferred by Typescript based on the function returns and not "forced" in the function signature.
} | ||
return [] | ||
} | ||
case 'title': { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar suggestion as with other case structure. I would suggest using default case.
switch (search.type) { | ||
case 'doi': { | ||
// convert to lower case | ||
const doi = search.term.toLowerCase() | ||
// validate if not already included | ||
const found = mentions.find(mention => mention.doi?.toLowerCase() === doi) | ||
if (found) { | ||
// flag item with DOI already processed | ||
mentionResultPerDoi.set(doi, {doi, status: 'alreadyImported', include: false}) | ||
return false | ||
} | ||
return true | ||
} | ||
return true | ||
} else { | ||
// flag invalid DOI entries | ||
mentionResultPerDoi.set(search.term, {doi:search.term, status: 'invalidDoi', include: false}) | ||
return false | ||
case 'openalex': | ||
case 'title': | ||
// flag invalid DOI entries | ||
mentionResultPerDoi.set(search.term, {doi: search.term, status: 'invalidDoi', include: false}) | ||
return false | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use default case or if/else as it seems only 2 options exist
Works as expected. There are a few small inconsistencies now:
|
c72db4b
to
c14a92e
Compare
|
|
Better OpenAlex support
Changes proposed in this pull request
How to test
docker compose down --volumes && docker compose build --parallel && docker compose up --scale data-generation=0
docker compose exec scrapers java -cp /usr/myjava/scrapers.jar nl.esciencecenter.rsd.scraper.doi.MainMentions
Closes #1312
PR Checklist:
docker-compose.yml