Skip to content

Commit

Permalink
fix date filters for recurringdonation stats
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosQ96 committed Nov 12, 2024
1 parent be46140 commit 1e00582
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/repositories/recurringDonationRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
12 changes: 6 additions & 6 deletions src/services/recurringDonationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
});
}
Expand Down Expand Up @@ -575,13 +575,13 @@ export const recurringDonationsStreamedCUsdTotalPerMonth = async (
.addSelect("TO_CHAR(recurringDonation.createdAt, '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),
});
}
Expand Down Expand Up @@ -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),
});
}
Expand Down

0 comments on commit 1e00582

Please sign in to comment.