Skip to content

Commit

Permalink
add cache to projectDonationSummary queries
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosQ96 committed May 3, 2024
1 parent 4fa78b5 commit 4e7db7a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/repositories/donationRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ export async function sumDonationValueUsdForQfRound(params: {
.andWhere(`projectEstimatedMatchingView."qfRoundId" = :qfRoundId`, {
qfRoundId,
})
.cache(`sumDonationValueUsdForQfRound-${projectId}-${qfRoundId}`, 60000)
.getOne();

return result?.sumValueUsd || 0;
Expand All @@ -503,6 +504,7 @@ export async function countUniqueDonors(projectId: number): Promise<number> {
)
.select(`projectDonationSummaryView."uniqueDonorsCount"`)
.where(`projectDonationSummaryView."projectId" = :projectId`, { projectId })
.cache(`countUniqueDonors-${projectId}`, 60000)
.getOne();

return result?.uniqueDonorsCount || 0;
Expand All @@ -514,6 +516,7 @@ export async function sumDonationValueUsd(projectId: number): Promise<number> {
)
.select(`projectDonationSummaryView."sumVerifiedDonations"`)
.where(`projectDonationSummaryView."projectId" = :projectId`, { projectId })
.cache(`sumDonationValueUsd-${projectId}`, 60000)
.getOne();

return result?.sumVerifiedDonations || 0;
Expand Down

0 comments on commit 4e7db7a

Please sign in to comment.