default 30% total citation weight for SS import posts
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 40s
Details
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 40s
Details
This commit is contained in:
parent
deb2c3c4de
commit
33241143ff
|
@ -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}
|
||||
|
|
Loading…
Reference in New Issue