Fix expirein used instead of keepuntil (#1788)
* Fix expirein used instead of keepuntil * Fix existing boost jobs
This commit is contained in:
parent
d53bc09773
commit
077727dced
|
@ -67,9 +67,9 @@ export async function onPaid ({ invoice, actId }, { tx }) {
|
|||
})
|
||||
|
||||
await tx.$executeRaw`
|
||||
INSERT INTO pgboss.job (name, data, retrylimit, retrybackoff, startafter, expirein)
|
||||
INSERT INTO pgboss.job (name, data, retrylimit, retrybackoff, startafter, keepuntil)
|
||||
VALUES ('expireBoost', jsonb_build_object('id', ${itemAct.itemId}::INTEGER), 21, true,
|
||||
now() + interval '30 days', interval '40 days')`
|
||||
now() + interval '30 days', now() + interval '40 days')`
|
||||
}
|
||||
|
||||
export async function onFail ({ invoice }, { tx }) {
|
||||
|
|
|
@ -461,11 +461,11 @@ async function createDbInvoice (actionType, args, context) {
|
|||
|
||||
// insert a job to check the invoice after it's set to expire
|
||||
await db.$executeRaw`
|
||||
INSERT INTO pgboss.job (name, data, retrylimit, retrybackoff, startafter, expirein, priority)
|
||||
INSERT INTO pgboss.job (name, data, retrylimit, retrybackoff, startafter, keepuntil, priority)
|
||||
VALUES ('checkInvoice',
|
||||
jsonb_build_object('hash', ${invoice.hash}::TEXT), 21, true,
|
||||
${expiresAt}::TIMESTAMP WITH TIME ZONE,
|
||||
${expiresAt}::TIMESTAMP WITH TIME ZONE - now() + interval '10m', 100)`
|
||||
${expiresAt}::TIMESTAMP WITH TIME ZONE + interval '10m', 100)`
|
||||
|
||||
// the HMAC is only returned during invoice creation
|
||||
// this makes sure that only the person who created this invoice
|
||||
|
|
|
@ -216,9 +216,9 @@ export async function onPaid ({ invoice, id }, context) {
|
|||
|
||||
if (item.boost > 0) {
|
||||
await tx.$executeRaw`
|
||||
INSERT INTO pgboss.job (name, data, retrylimit, retrybackoff, startafter, expirein)
|
||||
INSERT INTO pgboss.job (name, data, retrylimit, retrybackoff, startafter, keepuntil)
|
||||
VALUES ('expireBoost', jsonb_build_object('id', ${item.id}::INTEGER), 21, true,
|
||||
now() + interval '30 days', interval '40 days')`
|
||||
now() + interval '30 days', now() + interval '40 days')`
|
||||
}
|
||||
|
||||
if (item.parentId) {
|
||||
|
|
|
@ -137,15 +137,15 @@ export async function perform (args, context) {
|
|||
})
|
||||
|
||||
await tx.$executeRaw`
|
||||
INSERT INTO pgboss.job (name, data, retrylimit, retrybackoff, startafter, expirein)
|
||||
INSERT INTO pgboss.job (name, data, retrylimit, retrybackoff, startafter, keepuntil)
|
||||
VALUES ('imgproxy', jsonb_build_object('id', ${id}::INTEGER), 21, true,
|
||||
now() + interval '5 seconds', interval '1 day')`
|
||||
now() + interval '5 seconds', now() + interval '1 day')`
|
||||
|
||||
if (newBoost > 0) {
|
||||
await tx.$executeRaw`
|
||||
INSERT INTO pgboss.job (name, data, retrylimit, retrybackoff, startafter, expirein)
|
||||
INSERT INTO pgboss.job (name, data, retrylimit, retrybackoff, startafter, keepuntil)
|
||||
VALUES ('expireBoost', jsonb_build_object('id', ${id}::INTEGER), 21, true,
|
||||
now() + interval '30 days', interval '40 days')`
|
||||
now() + interval '30 days', now() + interval '40 days')`
|
||||
}
|
||||
|
||||
await performBotBehavior(args, context)
|
||||
|
|
|
@ -60,23 +60,23 @@ export async function performBotBehavior ({ text, id }, { me, tx }) {
|
|||
const deleteAt = getDeleteAt(text)
|
||||
if (deleteAt) {
|
||||
await tx.$queryRaw`
|
||||
INSERT INTO pgboss.job (name, data, startafter, expirein)
|
||||
INSERT INTO pgboss.job (name, data, startafter, keepuntil)
|
||||
VALUES (
|
||||
'deleteItem',
|
||||
jsonb_build_object('id', ${id}::INTEGER),
|
||||
${deleteAt}::TIMESTAMP WITH TIME ZONE,
|
||||
${deleteAt}::TIMESTAMP WITH TIME ZONE - now() + interval '1 minute')`
|
||||
${deleteAt}::TIMESTAMP WITH TIME ZONE + interval '1 minute')`
|
||||
}
|
||||
|
||||
const remindAt = getRemindAt(text)
|
||||
if (remindAt) {
|
||||
await tx.$queryRaw`
|
||||
INSERT INTO pgboss.job (name, data, startafter, expirein)
|
||||
INSERT INTO pgboss.job (name, data, startafter, keepuntil)
|
||||
VALUES (
|
||||
'reminder',
|
||||
jsonb_build_object('itemId', ${id}::INTEGER, 'userId', ${userId}::INTEGER),
|
||||
${remindAt}::TIMESTAMP WITH TIME ZONE,
|
||||
${remindAt}::TIMESTAMP WITH TIME ZONE - now() + interval '1 minute')`
|
||||
${remindAt}::TIMESTAMP WITH TIME ZONE + interval '1 minute')`
|
||||
await tx.reminder.create({
|
||||
data: {
|
||||
userId,
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
-- fix existing boost jobs
|
||||
UPDATE pgboss.job
|
||||
SET keepuntil = startafter + interval '10 days'
|
||||
WHERE name = 'expireBoost' AND state = 'created';
|
Loading…
Reference in New Issue