Skip to content

Commit 3a59668

Browse files
committed
rename view
1 parent 6acdd76 commit 3a59668

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

app/api/cron/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
2+
autoRenewFailedRecurringDonations,
23
charge,
34
logError,
4-
renewAutoCancelledDonations,
55
sendNewEmails,
66
} from "src";
77

@@ -19,7 +19,7 @@ export async function POST(req: Request) {
1919

2020
await charge();
2121
await sendNewEmails();
22-
await renewAutoCancelledDonations();
22+
await autoRenewFailedRecurringDonations();
2323

2424
return Response.json({ message: "OK" });
2525
} catch (err) {

db/migrations/99999999999999_views.sql

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ annual_tax_report_gavebrev_since,
1212
annual_tax_report_gaveskema,
1313
annual_tax_report_pending_update,
1414
charged_donations,
15-
charged_donations_internal,
1615
charged_donations_by_transfer,
1716
charged_donations_by_transfer_internal,
17+
charged_donations_internal,
1818
charged_memberships,
1919
charged_memberships_internal,
2020
charged_or_created_donations,
@@ -28,7 +28,7 @@ donations_to_email,
2828
donor_acquisition,
2929
donor_impact_report,
3030
failed_recurring_donations,
31-
failed_recurring_donations_to_auto_cancel,
31+
failed_recurring_donations_to_auto_renew,
3232
gavebrev_checkins_to_create,
3333
gwwc_money_moved,
3434
ignored_renewals,
@@ -612,7 +612,7 @@ select
612612
on failed_recurring_donations to reader_sensitive;
613613

614614
---------
615-
create view failed_recurring_donations_to_auto_cancel as
615+
create view failed_recurring_donations_to_auto_renew as
616616
with
617617
latest_charges as (
618618
select
@@ -636,11 +636,11 @@ select
636636
from
637637
latest_charges
638638
where
639-
rn <= 3
639+
rn <= 6
640640
group by
641641
donation_id
642642
having
643-
count(*) = 3
643+
count(*) = 6
644644
and bool_and(status = 'error')
645645
order by
646646
1
@@ -649,10 +649,10 @@ limit
649649

650650
grant
651651
select
652-
on failed_recurring_donations_to_auto_cancel to reader_sensitive;
652+
on failed_recurring_donations_to_auto_renew to reader_sensitive;
653653

654654
grant
655-
update on failed_recurring_donations_to_auto_cancel to writer;
655+
update on failed_recurring_donations_to_auto_renew to writer;
656656

657657
--------------------------------------
658658
create view annual_tax_report_const as

db/schema.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,10 +2217,10 @@ CREATE VIEW giveffektivt.failed_recurring_donations AS
22172217

22182218

22192219
--
2220-
-- Name: failed_recurring_donations_to_auto_cancel; Type: VIEW; Schema: giveffektivt; Owner: -
2220+
-- Name: failed_recurring_donations_to_auto_renew; Type: VIEW; Schema: giveffektivt; Owner: -
22212221
--
22222222

2223-
CREATE VIEW giveffektivt.failed_recurring_donations_to_auto_cancel AS
2223+
CREATE VIEW giveffektivt.failed_recurring_donations_to_auto_renew AS
22242224
WITH latest_charges AS (
22252225
SELECT c.donation_id,
22262226
c.status,
@@ -2231,9 +2231,9 @@ CREATE VIEW giveffektivt.failed_recurring_donations_to_auto_cancel AS
22312231
)
22322232
SELECT donation_id AS id
22332233
FROM latest_charges
2234-
WHERE (rn <= 3)
2234+
WHERE (rn <= 6)
22352235
GROUP BY donation_id
2236-
HAVING ((count(*) = 3) AND bool_and((status = 'error'::giveffektivt.charge_status)))
2236+
HAVING ((count(*) = 6) AND bool_and((status = 'error'::giveffektivt.charge_status)))
22372237
ORDER BY donation_id
22382238
LIMIT 2;
22392239

src/donation/failed.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
generateRenewPaymentUrl,
66
getDonationToUpdateQuickpayPaymentInfoById,
77
getFailedRecurringDonations,
8-
getFailedRecurringDonationsToAutoCancel,
8+
getFailedRecurringDonationsToAutoRenew,
99
logError,
1010
recreateQuickpayFailedRecurringDonation,
1111
sendFailedRecurringDonationEmail,
@@ -68,9 +68,9 @@ export async function getRenewPaymentLink(
6868
});
6969
}
7070

71-
export async function renewAutoCancelledDonations() {
71+
export async function autoRenewFailedRecurringDonations() {
7272
await dbExecuteInTransaction(async (db) => {
73-
const ids = await getFailedRecurringDonationsToAutoCancel(db);
73+
const ids = await getFailedRecurringDonationsToAutoRenew(db);
7474
await sendFailedRecurringDonationEmails(db, ids);
7575
});
7676
}

src/donation/repository.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,12 @@ export async function getFailedRecurringDonations(
237237
return (await client.query("select * from failed_recurring_donations")).rows;
238238
}
239239

240-
export async function getFailedRecurringDonationsToAutoCancel(
240+
export async function getFailedRecurringDonationsToAutoRenew(
241241
client: PoolClient,
242242
) {
243243
return (
244244
await client.query(
245-
"select id from failed_recurring_donations_to_auto_cancel for update skip locked",
245+
"select id from failed_recurring_donations_to_auto_renew for update skip locked",
246246
)
247247
).rows.map((d) => d.id);
248248
}

0 commit comments

Comments
 (0)