From 513699686dfc7e4163ccc6f8b213404967bee1c1 Mon Sep 17 00:00:00 2001 From: Mohammad Ranjbar Z Date: Tue, 5 Dec 2023 16:42:55 +0330 Subject: [PATCH] Fix query to just add donation for qfRound histories that have full data --- src/repositories/qfRoundHistoryRepository.ts | 10 +++++++--- src/services/donationService.ts | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/repositories/qfRoundHistoryRepository.ts b/src/repositories/qfRoundHistoryRepository.ts index ff02057b2..06257eaac 100644 --- a/src/repositories/qfRoundHistoryRepository.ts +++ b/src/repositories/qfRoundHistoryRepository.ts @@ -50,9 +50,13 @@ export const getQfRoundHistoriesThatDontHaveRelatedDonations = 'd', 'q.distributedFundTxHash = d.transactionId AND q.projectId = d.projectId AND d.distributedFundQfRoundId IS NOT NULL', ) - .where( - 'd.id IS NULL AND q.matchingFund IS NOT NULL AND q.matchingFund != 0', - ) + .where('d.id IS NULL') + .andWhere('q.matchingFund IS NOT NULL') + .andWhere('q.matchingFund != 0') + .andWhere('q.distributedFundTxHash IS NOT NUL') + .andWhere('q.distributedFundNetwork IS NOT NUL') + .andWhere('q.matchingFundCurrency IS NOT NUL') + .andWhere('q.matchingFundAmount IS NOT NUL') .getMany(); } catch (e) { logger.error('getQfRoundHistoriesThatDontHaveRelatedDonations error', e); diff --git a/src/services/donationService.ts b/src/services/donationService.ts index 5edc689d3..3fdbfefb6 100644 --- a/src/services/donationService.ts +++ b/src/services/donationService.ts @@ -515,6 +515,10 @@ export const insertDonationsFromQfRoundHistory = async (): Promise => { d."transactionId" = q."distributedFundTxHash" AND d."projectId" = q."projectId" AND d."distributedFundQfRoundId" = q."qfRoundId" AND + q."matchingFundAmount" IS NOT NULL AND + q."matchingFundCurrency" IS NOT NULL AND + q."distributedFundNetwork" IS NOT NULL AND + q."distributedFundTxHash" IS NOT NULL AND q."matchingFund" IS NOT NULL AND q."matchingFund" != 0 )