Skip to content

Commit e85f40e

Browse files
committed
fix territory reward percent default (should be 30)
1 parent 9fc819e commit e85f40e

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
-- refund the founder revenue difference
2+
WITH "SubActRevenue" AS (
3+
SELECT "SubAct"."subName", "SubAct"."userId", FLOOR(SUM("SubAct"."msats") * 2 * 0.2) AS "msats"
4+
FROM "SubAct" JOIN "Sub" ON "SubAct"."subName" = "Sub"."name" AND "Sub"."rewardsPct" = 50
5+
WHERE "SubAct"."type" = 'REVENUE' AND "SubAct".created_at > '2024-09-19T21:38:43.918Z'
6+
GROUP BY "SubAct"."subName", "SubAct"."userId"
7+
), "FounderRevenue" AS (
8+
SELECT "userId", SUM("msats") AS "msats"
9+
FROM "SubActRevenue"
10+
GROUP BY "userId"
11+
), insert_acts AS (
12+
INSERT INTO "SubAct" ("subName", "userId", "msats", "type")
13+
SELECT "SubActRevenue"."subName", "SubActRevenue"."userId", "SubActRevenue"."msats", 'REVENUE'
14+
FROM "SubActRevenue"
15+
)
16+
UPDATE users SET msats = users.msats + "FounderRevenue"."msats"
17+
FROM "FounderRevenue"
18+
WHERE "FounderRevenue"."userId" = "users"."id";
19+
20+
-- set the default territory cut to 30%
21+
ALTER TABLE "Sub" ALTER COLUMN "rewardsPct" SET DEFAULT 30;
22+
23+
-- update all subs to 30%
24+
UPDATE "Sub" SET "rewardsPct" = 30 WHERE "rewardsPct" = 50;

prisma/schema.prisma

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ model Sub {
778778
allowFreebies Boolean @default(true)
779779
baseCost Int @default(1)
780780
replyCost Int @default(1)
781-
rewardsPct Int @default(50)
781+
rewardsPct Int @default(30)
782782
desc String?
783783
status Status @default(ACTIVE)
784784
statusUpdatedAt DateTime?

0 commit comments

Comments
 (0)