Skip to content

Commit

Permalink
src/donations: Include guaranteed donations in listPublic
Browse files Browse the repository at this point in the history
Removed unnecessary count query. Replaced with the length of the findMany query
  • Loading branch information
sashko9807 committed Oct 20, 2023
1 parent 3f48f56 commit 764731d
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions apps/api/src/donations/donations.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,10 @@ export class DonationsService {
pageSize?: number,
): Promise<ListDonationsDto<DonationBaseDto>> {
const data = await this.prisma.donation.findMany({
where: { status, targetVault: { campaign: { id: campaignId } } },
where: {
OR: [{ status: status }, { status: DonationStatus.guaranteed }],
targetVault: { campaign: { id: campaignId } },
},
orderBy: [{ updatedAt: 'desc' }],
select: {
id: true,
Expand All @@ -308,13 +311,9 @@ export class DonationsService {
take: pageSize ? pageSize : undefined,
})

const count = await this.prisma.donation.count({
where: { status, targetVault: { campaign: { id: campaignId } } },
})

const result = {
items: data,
total: count,
total: data.length,
}

return result
Expand Down

0 comments on commit 764731d

Please sign in to comment.