Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src/donations: Get uniqueDonors by billingName #586

Merged
merged 1 commit into from
Dec 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions apps/api/src/donations/donations.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -772,12 +772,9 @@ export class DonationsService {
async getDonorsCount() {
const donorsCount = await this.prisma.$queryRaw<{
count: number
}>`SELECT COUNT (*) FROM (SELECT DISTINCT billing_email FROM donations WHERE status::text=${DonationStatus.succeeded}) AS unique_donors`
}>`SELECT COUNT (*)::INTEGER FROM (SELECT DISTINCT billing_name FROM donations WHERE status::text=${DonationStatus.succeeded}) AS unique_donors`

//Return result is BigInt which can't be serialized. Convert result to string first.
const uniqueDonors = donorsCount[0].count.toString()

return { count: Number(uniqueDonors) }
return { count: donorsCount[0].count }
}

/**
Expand Down
Loading