diff --git a/src/repositories/recurringDonationRepository.ts b/src/repositories/recurringDonationRepository.ts index 7dec0dea1..d7b05cb99 100644 --- a/src/repositories/recurringDonationRepository.ts +++ b/src/repositories/recurringDonationRepository.ts @@ -106,7 +106,8 @@ export const updateRecurringDonationFromTheStreamDonations = async ( SELECT COALESCE(SUM(d."amount"), 0) FROM donation as d WHERE d."recurringDonationId" = $1 - ) + ), + "updatedAt" = NOW() WHERE "id" = $1 `, [recurringDonationId], diff --git a/src/services/recurringDonationService.ts b/src/services/recurringDonationService.ts index 647b187cd..5241fd2c9 100644 --- a/src/services/recurringDonationService.ts +++ b/src/services/recurringDonationService.ts @@ -529,13 +529,13 @@ export const recurringDonationsStreamedCUsdTotal = async ( ).select('COALESCE(SUM(recurringDonation.totalUsdStreamed), 0)', 'total'); if (fromDate) { - query.andWhere('recurringDonation.createdAt >= :fromDate', { + query.andWhere('recurringDonation.updatedAt >= :fromDate', { fromDate: new Date(fromDate), }); } if (toDate) { - query.andWhere('recurringDonation.createdAt <= :toDate', { + query.andWhere('recurringDonation.updatedAt <= :toDate', { toDate: new Date(toDate), }); } @@ -572,16 +572,16 @@ export const recurringDonationsStreamedCUsdTotalPerMonth = async ( ): Promise => { const query = RecurringDonation.createQueryBuilder('recurringDonation') .select('SUM(recurringDonation.totalUsdStreamed)', 'total') - .addSelect("TO_CHAR(recurringDonation.createdAt, 'YYYY/MM')", 'date'); + .addSelect("TO_CHAR(recurringDonation.updatedAt, 'YYYY/MM')", 'date'); if (fromDate) { - query.andWhere('recurringDonation.createdAt >= :fromDate', { + query.andWhere('recurringDonation.updatedAt >= :fromDate', { fromDate: new Date(fromDate), }); } if (toDate) { - query.andWhere('recurringDonation.createdAt <= :toDate', { + query.andWhere('recurringDonation.updatedAt <= :toDate', { toDate: new Date(toDate), }); } @@ -627,13 +627,13 @@ export const recurringDonationsTotalPerToken = async (params: { .having('SUM(recurringDonation.totalUsdStreamed) > 0'); if (fromDate) { - query.andWhere('recurringDonation.createdAt >= :fromDate', { + query.andWhere('recurringDonation.updatedAt >= :fromDate', { fromDate: new Date(fromDate), }); } if (toDate) { - query.andWhere('recurringDonation.createdAt <= :toDate', { + query.andWhere('recurringDonation.updatedAt <= :toDate', { toDate: new Date(toDate), }); }