fix territory reward percent default (should be 30)

This commit is contained in:
k00b 2025-04-22 13:16:58 -05:00
parent 9fc819ec37
commit e85f40e9ba
2 changed files with 25 additions and 1 deletions

View File

@ -0,0 +1,24 @@
-- refund the founder revenue difference
WITH "SubActRevenue" AS (
SELECT "SubAct"."subName", "SubAct"."userId", FLOOR(SUM("SubAct"."msats") * 2 * 0.2) AS "msats"
FROM "SubAct" JOIN "Sub" ON "SubAct"."subName" = "Sub"."name" AND "Sub"."rewardsPct" = 50
WHERE "SubAct"."type" = 'REVENUE' AND "SubAct".created_at > '2024-09-19T21:38:43.918Z'
GROUP BY "SubAct"."subName", "SubAct"."userId"
), "FounderRevenue" AS (
SELECT "userId", SUM("msats") AS "msats"
FROM "SubActRevenue"
GROUP BY "userId"
), insert_acts AS (
INSERT INTO "SubAct" ("subName", "userId", "msats", "type")
SELECT "SubActRevenue"."subName", "SubActRevenue"."userId", "SubActRevenue"."msats", 'REVENUE'
FROM "SubActRevenue"
)
UPDATE users SET msats = users.msats + "FounderRevenue"."msats"
FROM "FounderRevenue"
WHERE "FounderRevenue"."userId" = "users"."id";
-- set the default territory cut to 30%
ALTER TABLE "Sub" ALTER COLUMN "rewardsPct" SET DEFAULT 30;
-- update all subs to 30%
UPDATE "Sub" SET "rewardsPct" = 30 WHERE "rewardsPct" = 50;

View File

@ -778,7 +778,7 @@ model Sub {
allowFreebies Boolean @default(true)
baseCost Int @default(1)
replyCost Int @default(1)
rewardsPct Int @default(50)
rewardsPct Int @default(30)
desc String?
status Status @default(ACTIVE)
statusUpdatedAt DateTime?