From 33241143ff82b2fe3eb9f7b210ca9da444960ce8 Mon Sep 17 00:00:00 2001 From: Ladd Hoffman Date: Sat, 20 Apr 2024 22:36:04 -0500 Subject: [PATCH] default 30% total citation weight for SS import posts --- backend/src/import-from-ss.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/src/import-from-ss.js b/backend/src/import-from-ss.js index ac0b3c3..20106af 100644 --- a/backend/src/import-from-ss.js +++ b/backend/src/import-from-ss.js @@ -63,7 +63,7 @@ const fetchPaperInfo = async (paperId, retryDelay = 5000) => { return paper; }; -const getAuthorsInfo = async (paper) => Promise.mapSeries( +const getOrCreateAuthor = async (paper) => Promise.mapSeries( paper.authors.filter((x) => !!x.authorId), async ({ authorId }) => { // Check if we already have an account for each author @@ -94,19 +94,20 @@ const getAuthorsInfo = async (paper) => Promise.mapSeries( ); const generatePost = async (paper) => { - const authorsInfo = await getAuthorsInfo(paper); + const authorsInfo = await getOrCreateAuthor(paper); if (!authorsInfo.length) { throw new Error('Paper has no authors with id'); } + const PERCENT_TO_CITATIONS = 30; const firstAuthorWallet = new ethers.Wallet(authorsInfo[0].authorPrivKey); - const eachAuthorWeightPercent = Math.floor(100 / authorsInfo.length); + const eachAuthorWeightPercent = Math.floor(PERCENT_TO_CITATIONS / authorsInfo.length); const authors = authorsInfo.map(({ authorAddress }) => ({ weightPercent: eachAuthorWeightPercent, authorAddress, })); // Make sure author weights sum to 100 const totalAuthorsWeight = authors.reduce((t, { weightPercent }) => t + weightPercent, 0); - authors[0].weightPercent += 100 - totalAuthorsWeight; + authors[0].weightPercent += PERCENT_TO_CITATIONS - totalAuthorsWeight; const content = `Semantic Scholar paper ${paper.paperId} ${paper.title}