Skip to content

Commit

Permalink
Fix query to just add donation for qfRound histories that have full data
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadranjbarz committed Dec 5, 2023
1 parent 372f3f3 commit 5136996
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/repositories/qfRoundHistoryRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/services/donationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,10 @@ export const insertDonationsFromQfRoundHistory = async (): Promise<void> => {
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
)
Expand Down

0 comments on commit 5136996

Please sign in to comment.