Skip to content

Commit

Permalink
add distinct to recurring donation count
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosQ96 committed Nov 19, 2024
1 parent d30ad0f commit fc407fa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/services/recurringDonationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ export const recurringDonationsCountPerDateRange = async (
onlyVerified?: boolean,
): Promise<number> => {
const query = RecurringDonation.createQueryBuilder('recurringDonation')
.select('COALESCE(COUNT(recurringDonation.id), 0)', 'count')
.select('COALESCE(COUNT(DISTINCT recurringDonation.id), 0)', 'count')
.innerJoin('recurringDonation.donations', 'donations')
.where('recurringDonation.status != :status', {
status: RECURRING_DONATION_STATUS.FAILED,
Expand Down Expand Up @@ -476,7 +476,7 @@ export const recurringDonationsCountPerDateRangePerMonth = async (
onlyVerified?: boolean,
): Promise<ResourcesTotalPerMonthAndYear[]> => {
const query = RecurringDonation.createQueryBuilder('recurringDonation')
.select('COUNT(recurringDonation.id)', 'total')
.select('COUNT(DISTINCT recurringDonation.id)', 'total')
.addSelect("TO_CHAR(recurringDonation.createdAt, 'YYYY/MM')", 'date')
.innerJoin('recurringDonation.donations', 'donations')
.where('recurringDonation.status != :status', {
Expand Down Expand Up @@ -675,7 +675,7 @@ export const recurringDonationsCountPerToken = async (params: {
const { fromDate, toDate, networkId, onlyVerified } = params;
const query = RecurringDonation.createQueryBuilder('recurringDonation')
.select('donations.currency', 'token')
.addSelect('COALESCE(COUNT(recurringDonation.id), 0)', 'total')
.addSelect('COALESCE(COUNT(DISTINCT recurringDonation.id), 0)', 'total')
.innerJoin('recurringDonation.donations', 'donations')
.where('recurringDonation.status != :status', {
status: RECURRING_DONATION_STATUS.FAILED,
Expand Down

0 comments on commit fc407fa

Please sign in to comment.