Skip to content

Commit f215cb7

Browse files
imilchevsashko9807
authored andcommitted
prefix payments queries with schema name (#693)
Signed-off-by: Ivan Milchev <[email protected]>
1 parent 0baba3a commit f215cb7

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

apps/api/src/campaign/campaign.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,16 @@ export class CampaignService {
110110
v.campaign_id as id
111111
FROM api.vaults v
112112
LEFT JOIN (
113-
SELECT
113+
SELECT
114114
target_vault_id,
115115
COUNT(d.id) FILTER (WHERE d.payment_id = p.id AND p.status::text = 'succeeded' OR p.status::text = 'guaranteed') AS donors,
116116
sum(d.amount) FILTER (WHERE d.payment_id = p.id AND p.status::text = 'succeeded') as reached,
117117
sum(d.amount) FILTER (WHERE d.payment_id = p.id AND p.status::text = 'guaranteed') as guaranteed
118118
FROM api.donations d
119-
INNER JOIN payments as p ON p.id = d.payment_id
119+
INNER JOIN api.payments as p ON p.id = d.payment_id
120120
GROUP BY target_vault_id
121121
) as d
122-
ON d.target_vault_id = v.id
122+
ON d.target_vault_id = v.id
123123
LEFT JOIN (
124124
SELECT source_vault_id, sum(amount) as "withdrawnAmount"
125125
FROM api.withdrawals w

apps/api/src/donations/donations.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ export class DonationsService {
689689
async getDonorsCount() {
690690
const donorsCount = await this.prisma.$queryRaw<{
691691
count: number
692-
}>`SELECT COUNT (*)::INTEGER FROM (SELECT DISTINCT billing_name FROM payments WHERE status::text=${PaymentStatus.succeeded}) AS unique_donors`
692+
}>`SELECT COUNT (*)::INTEGER FROM (SELECT DISTINCT billing_name FROM api.payments WHERE status::text=${PaymentStatus.succeeded}) AS unique_donors`
693693

694694
return { count: donorsCount[0].count }
695695
}

apps/api/src/statistics/statistics.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class StatisticsService {
3333

3434
return this.prisma.$queryRaw`
3535
SELECT SUM(d.amount)::INTEGER, COUNT(d.id)::INTEGER, ${date}
36-
FROM api.donations d, payments p WHERE p.status::text = 'succeeded'
36+
FROM api.donations d, api.payments p WHERE p.status::text = 'succeeded'
3737
${Prisma.sql`AND target_vault_id IN ( SELECT id from api.vaults WHERE campaign_id = ${campaignId}::uuid)`}
3838
${group}
3939
ORDER BY date ASC `
@@ -42,7 +42,7 @@ export class StatisticsService {
4242
async listUniqueDonations(campaignId: string): Promise<UniqueDonationsDto[]> {
4343
return this.prisma.$queryRaw`
4444
SELECT d.amount::INTEGER, COUNT(d.id)::INTEGER AS count
45-
FROM api.donations d, payments p WHERE p.status::text = 'succeeded'
45+
FROM api.donations d, api.payments p WHERE p.status::text = 'succeeded'
4646
${Prisma.sql`AND target_vault_id IN ( SELECT id from api.vaults WHERE campaign_id = ${campaignId}::uuid)`}
4747
GROUP BY d.amount
4848
ORDER BY amount ASC`
@@ -51,7 +51,7 @@ export class StatisticsService {
5151
async listHourlyDonations(campaignId: string): Promise<HourlyDonationsDto[]> {
5252
return this.prisma.$queryRaw`
5353
SELECT EXTRACT(HOUR from d.created_at)::INTEGER AS hour, COUNT(d.id)::INTEGER AS count
54-
FROM api.donations d, payments p WHERE p.status::text = 'succeeded'
54+
FROM api.donations d, api.payments p WHERE p.status::text = 'succeeded'
5555
${Prisma.sql`AND target_vault_id IN ( SELECT id from api.vaults WHERE campaign_id = ${campaignId}::uuid)`}
5656
GROUP BY hour
5757
ORDER BY hour ASC`

0 commit comments

Comments
 (0)