Skip to content

Commit

Permalink
more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
ericjeangirard committed Oct 22, 2024
1 parent 6a2700f commit 3d4fe2c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server/src/utils/works.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ const getOpenAlexAffiliation = (author) => {
};

const getOpenAlexPublicationsByYear = (options, cursor = '*', previousResponse = [], remainingTries = 3) => {
console.log('getOpenAlexPublicationsByYear', `MAX_OPENALEX = ${MAX_OPENALEX}`);
console.log('getOpenAlexPublicationsByYear', `MAX_OPENALEX = ${MAX_OPENALEX}, currentResponseLength = ${previousResponse.length}`);
let url = `https://api.openalex.org/works?per_page=${process.env.OPENALEX_PER_PAGE}`;
url += '&filter=is_paratext:false';
url += `,publication_year:${Number(options.year)}-${Number(options?.year)}`;
Expand All @@ -365,6 +365,7 @@ const getOpenAlexPublicationsByYear = (options, cursor = '*', previousResponse =
.then((response) => {
if (response.ok) return response.json();
if (response.status === 429) {
console.log('Error 429', 'Getting error 429 from OpenAlex');
return new Promise((resolve) => setTimeout(resolve, Math.round(Math.random() * 1000))).then(() => getOpenAlexPublicationsByYear(options, cursor, previousResponse));
}
console.error(`Error while fetching ${url} :`);
Expand Down

0 comments on commit 3d4fe2c

Please sign in to comment.