From b1b59e6df5ddbfcca2fcd87cfab75e2f412e49c6 Mon Sep 17 00:00:00 2001 From: Ladd Hoffman Date: Fri, 26 Apr 2024 22:48:52 -0500 Subject: [PATCH] ignore cited papers with no authors --- backend/src/import-from-ss.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/backend/src/import-from-ss.js b/backend/src/import-from-ss.js index 72d4ef7..4eb5485 100644 --- a/backend/src/import-from-ss.js +++ b/backend/src/import-from-ss.js @@ -146,19 +146,23 @@ const importPaper = async (paper) => { const { paperId } = paper; const references = paper.references.filter((x) => !!x.paperId); const eachCitationWeightPercent = Math.floor(PPM_TO_CITATIONS / references.length); - const citations = await Promise.mapSeries( + const citations = (await Promise.mapSeries( references, async (citedPaper) => { // We need to fetch this paper so we can generate the post we WOULD add to the forum. // That way, if we later add the cited paper to the blockchain it will have the correct hash. // The forum allows dangling citations to support this use case. - const citedPost = await generatePost(citedPaper); - return { - weightPPM: eachCitationWeightPercent, - targetPostId: citedPost.hash, - }; + try { + const citedPost = await generatePost(citedPaper); + return { + weightPPM: eachCitationWeightPercent, + targetPostId: citedPost.hash, + }; + } catch (e) { + return null; + } }, - ); + )).filter((x) => !!x); // Make sure citation weights sum to the designated total if (citations.length) {