fix expire boost unit
This commit is contained in:
parent
b4e143460b
commit
ad9a65ce78
|
@ -0,0 +1,18 @@
|
|||
CREATE OR REPLACE FUNCTION expire_boost_jobs()
|
||||
RETURNS INTEGER
|
||||
LANGUAGE plpgsql
|
||||
AS $$
|
||||
DECLARE
|
||||
BEGIN
|
||||
INSERT INTO pgboss.job (name, data, retrylimit, retrybackoff, startafter, expirein)
|
||||
SELECT 'expireBoost', jsonb_build_object('id', "Item".id), 21, true, now(), interval '1 days'
|
||||
FROM "Item"
|
||||
WHERE "Item".boost > 0 ON CONFLICT DO NOTHING;
|
||||
return 0;
|
||||
EXCEPTION WHEN OTHERS THEN
|
||||
return 0;
|
||||
END;
|
||||
$$;
|
||||
|
||||
SELECT expire_boost_jobs();
|
||||
DROP FUNCTION IF EXISTS expire_boost_jobs;
|
|
@ -16,7 +16,7 @@ export async function expireBoost ({ data: { id }, models }) {
|
|||
AND "itemId" = ${Number(id)}::INTEGER
|
||||
)
|
||||
UPDATE "Item"
|
||||
SET boost = COALESCE(boost.cur_msats, 0), "oldBoost" = COALESCE(boost.old_msats, 0)
|
||||
SET boost = COALESCE(boost.cur_msats, 0) / 1000, "oldBoost" = COALESCE(boost.old_msats, 0) / 1000
|
||||
FROM boost
|
||||
WHERE "Item".id = ${Number(id)}::INTEGER`
|
||||
],
|
||||
|
|
Loading…
Reference in New Issue