From bc4b32766314bc860c984aed7a809808c57a6e91 Mon Sep 17 00:00:00 2001 From: Raul Glogovetan Date: Mon, 10 Jun 2024 15:46:12 +0300 Subject: [PATCH] Fix: `updateContributorsWithReputation` rep fallback values --- .../updateContributorsWithReputation/src/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/amplify/backend/function/updateContributorsWithReputation/src/index.js b/amplify/backend/function/updateContributorsWithReputation/src/index.js index 7660931263..9536f0baa0 100644 --- a/amplify/backend/function/updateContributorsWithReputation/src/index.js +++ b/amplify/backend/function/updateContributorsWithReputation/src/index.js @@ -143,6 +143,8 @@ exports.handler = async (event) => { const allNativeDomainIds = data?.getColony?.domains?.items?.map(({ nativeId }) => nativeId) ?? []; + console.log({ allNativeDomainIds }) + const promiseResults = await Promise.allSettled( allNativeDomainIds.map(async (nativeDomainId) => { const { skillId } = await colonyClient.getDomain(nativeDomainId); @@ -181,6 +183,8 @@ exports.handler = async (event) => { const totalAddresses = sortedAddresses.length; + console.log({ totalAddresses }) + const promiseStatuses = await Promise.allSettled( sortedAddresses.map(async ({ address, reputationBN }, idx) => { const contributorAddress = getAddress(address); @@ -189,12 +193,12 @@ exports.handler = async (event) => { const colonyReputationPercentage = contributorRepDecimal .mul(100) .div(totalRepInColony.toString()) - .toNumber(); + .toNumber() || 0; const domainReputationPercentage = contributorRepDecimal .mul(100) .div(totalRepInDomain.toString()) - .toNumber(); + .toNumber() || 0; const contributorReputationId = `${colonyAddress}_${nativeDomainId}_${contributorAddress}`; const colonyContributorId = `${colonyAddress}_${contributorAddress}`; @@ -226,6 +230,8 @@ exports.handler = async (event) => { const type = getContributorType(totalAddresses, idx, createdAt); + console.log({ type, colonyReputationPercentage, contributorAddress, contributorRepDecimal, domainReputationPercentage, reputation }) + await updateColonyContributorInDb({ id: colonyContributorId, type,