diff --git a/src/repositories/donationRepository.ts b/src/repositories/donationRepository.ts index 4b649faaf..5ec0e093d 100644 --- a/src/repositories/donationRepository.ts +++ b/src/repositories/donationRepository.ts @@ -661,12 +661,14 @@ export async function isVerifiedDonationExistsInQfRound(params: { ` SELECT EXISTS ( SELECT 1 - FROM donation + FROM donation as d + INNER JOIN "qf_round" as qr on qr.id = $1 WHERE - status = 'verified' AND - "qfRoundId" = $1 AND - "projectId" = $2 AND - "userId" = $3 + d.status = 'verified' AND + d."qfRoundId" = $1 AND + d."projectId" = $2 AND + d."userId" = $3 AND + d."createdAt" >= qr."beginDate" AND d."createdAt" <= qr."endDate" ) AS exists; `, [params.qfRoundId, params.projectId, params.userId], diff --git a/src/resolvers/donationResolver.test.ts b/src/resolvers/donationResolver.test.ts index 11b80dace..dfb19d3f1 100644 --- a/src/resolvers/donationResolver.test.ts +++ b/src/resolvers/donationResolver.test.ts @@ -715,7 +715,7 @@ function doesDonatedToProjectInQfRoundTestCases() { await saveDonationDirectlyToDb( createDonationData({ status: DONATION_STATUS.VERIFIED, - createdAt: moment().add(50, 'days').toDate(), + createdAt: moment().add(8, 'days').toDate(), valueUsd: 20, qfRoundId: qfRound.id, }),