Skip to content

Commit

Permalink
fix(routes): error in openalex get data
Browse files Browse the repository at this point in the history
  • Loading branch information
ahonestla committed Oct 23, 2023
1 parent 3ba25d6 commit 6a8a859
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions server/src/routes/openalex/open-alex-to-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function openAlexToPublications(publicationList) {
]),
[],
);
const affiliationIds = publication?.authorships?.reduce((acc, { institutions = {} }) => ([...acc, institutions?.id]), []);
const affiliationIds = publication?.authorships?.flatMap(({ institutions = [] }) => institutions.map(({ id }) => id));

publications[publication.id] = {
id: publication.id,
Expand All @@ -66,9 +66,9 @@ export function openAlexToPublications(publicationList) {
export function openAlexToStructures(publicationList) {
const structures = {};

publicationList.forEach(({ affiliations = [] }) => {
if (affiliations) {
affiliations.forEach(({ id, display_name: name, country_code: country }) => {
publicationList.forEach(({ authorships = [] }) => {
authorships.forEach(({ institutions = [] }) => {
institutions.forEach(({ id, display_name: name, country_code: country }) => {
if (!(id in structures)) {
structures[id] = {
name: name.toLowerCase(),
Expand All @@ -77,7 +77,7 @@ export function openAlexToStructures(publicationList) {
};
}
});
}
});
});

return structures;
Expand Down

0 comments on commit 6a8a859

Please sign in to comment.