From df28ddd495c31a1321093b94a5b687aabc9e8d45 Mon Sep 17 00:00:00 2001 From: hichri-louay Date: Mon, 30 Oct 2023 15:24:16 +0100 Subject: [PATCH 1/4] remove console log errors --- web3/wallets.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web3/wallets.js b/web3/wallets.js index 408cc109..3c7c311f 100644 --- a/web3/wallets.js +++ b/web3/wallets.js @@ -557,7 +557,7 @@ const getNetworkByToken = async (idCrypto) => { const result = await rp.request(options) results.push(result) } catch (err) { - console.error('Error fetching data for batch:', err) + // Handle the error as needed, e.g., retry or skip } }) @@ -820,7 +820,7 @@ exports.getallCryptoMarket = async (startVariable) => { const response = await rp(options) result.push(response) } catch (error) { - console.error('Error fetching prices:', error) + throw new Error('Error fetching prices') } } From cc46a774ba41d3a896961fe965e626aa7f6e66f5 Mon Sep 17 00:00:00 2001 From: hichri-louay Date: Thu, 2 Nov 2023 16:08:05 +0100 Subject: [PATCH 2/4] add condition for updates fb page --- manager/oracles.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/manager/oracles.js b/manager/oracles.js index ecedcdc2..04e1517f 100644 --- a/manager/oracles.js +++ b/manager/oracles.js @@ -1321,11 +1321,13 @@ exports.updateFacebookPages = async (UserId, accessToken, isInsta = false) => { var resMedia = (await rp.get( media)).data page.instagram_username = resMedia.username } - await FbPage.updateOne( - { id: res.data[i].id, UserId }, - { $set: page }, - { upsert: true } - ) + const existingPage = await FbPage.findOne({ id: res.data[i].id, UserId }); + existingPage && await FbPage.updateOne( + { id: res.data[i].id, UserId }, + { $set: page }, + { upsert: true } + ) + } if (!res.paging || !res.paging.next) { break @@ -1392,11 +1394,12 @@ exports.getFacebookPages = async (UserId, accessToken, isInsta = false) => { var resMedia = (await rp.get(media)).data page.instagram_username = resMedia.username } - await FbPage.updateOne( - { id: res.data[i].id, UserId }, - { $set: page }, - { upsert: true } - ) + const existingPage = await FbPage.findOne({ id: res.data[i].id, UserId }); + existingPage && await FbPage.updateOne( + { id: res.data[i].id, UserId }, + { $set: page }, + { upsert: true } + ) } if (!res.paging || !res.paging.next) { break From a2ec01c2e822920f72a3bff12a4cebb25d00fd7a Mon Sep 17 00:00:00 2001 From: hichri-louay Date: Thu, 2 Nov 2023 16:43:50 +0100 Subject: [PATCH 3/4] remove condition --- manager/oracles.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/manager/oracles.js b/manager/oracles.js index 04e1517f..a989a691 100644 --- a/manager/oracles.js +++ b/manager/oracles.js @@ -1321,8 +1321,7 @@ exports.updateFacebookPages = async (UserId, accessToken, isInsta = false) => { var resMedia = (await rp.get( media)).data page.instagram_username = resMedia.username } - const existingPage = await FbPage.findOne({ id: res.data[i].id, UserId }); - existingPage && await FbPage.updateOne( + await FbPage.updateOne( { id: res.data[i].id, UserId }, { $set: page }, { upsert: true } @@ -1394,8 +1393,7 @@ exports.getFacebookPages = async (UserId, accessToken, isInsta = false) => { var resMedia = (await rp.get(media)).data page.instagram_username = resMedia.username } - const existingPage = await FbPage.findOne({ id: res.data[i].id, UserId }); - existingPage && await FbPage.updateOne( + await FbPage.updateOne( { id: res.data[i].id, UserId }, { $set: page }, { upsert: true } From f01e8f8f6cca14fc69eeab19694d43d4af03623a Mon Sep 17 00:00:00 2001 From: hichri-louay Date: Wed, 15 Nov 2023 11:23:42 +0100 Subject: [PATCH 4/4] add a default value for undefined token decimals --- controllers/campaign.controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/campaign.controller.js b/controllers/campaign.controller.js index b1c59059..810364fc 100644 --- a/controllers/campaign.controller.js +++ b/controllers/campaign.controller.js @@ -2761,7 +2761,7 @@ module.exports.campaignsStatistics = async (req, res) => { const payedAmountInCryptoCurrency = new Big( link.payedAmount - ).div(decimalPower.pow(getDecimal(tokenName))) + ).div(decimalPower.pow(getDecimal(tokenName) ?? 18)) const cryptoUnitPriceInUSD = new Big( Crypto[tokenName].price )