Skip to content

Commit a8b2882

Browse files
committed
wip: zen
1 parent a03a2b6 commit a8b2882

1 file changed

Lines changed: 30 additions & 14 deletions

File tree

packages/console/core/script/lookup-user.ts

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import { Database, and, eq, sql } from "../src/drizzle/index.js"
22
import { AuthTable } from "../src/schema/auth.sql.js"
33
import { UserTable } from "../src/schema/user.sql.js"
4-
import { BillingTable, PaymentTable, SubscriptionTable, BlackPlans, UsageTable } from "../src/schema/billing.sql.js"
4+
import {
5+
BillingTable,
6+
PaymentTable,
7+
SubscriptionTable,
8+
BlackPlans,
9+
UsageTable,
10+
LiteTable,
11+
} from "../src/schema/billing.sql.js"
512
import { WorkspaceTable } from "../src/schema/workspace.sql.js"
613
import { KeyTable } from "../src/schema/key.sql.js"
714
import { BlackData } from "../src/black.js"
@@ -72,19 +79,22 @@ else {
7279
workspaceID: UserTable.workspaceID,
7380
workspaceName: WorkspaceTable.name,
7481
role: UserTable.role,
75-
subscribed: SubscriptionTable.timeCreated,
82+
black: SubscriptionTable.timeCreated,
83+
lite: LiteTable.timeCreated,
7684
})
7785
.from(UserTable)
7886
.rightJoin(WorkspaceTable, eq(WorkspaceTable.id, UserTable.workspaceID))
7987
.leftJoin(SubscriptionTable, eq(SubscriptionTable.userID, UserTable.id))
88+
.leftJoin(LiteTable, eq(LiteTable.userID, UserTable.id))
8089
.where(eq(UserTable.accountID, accountID))
8190
.then((rows) =>
8291
rows.map((row) => ({
8392
userID: row.userID,
8493
workspaceID: row.workspaceID,
8594
workspaceName: row.workspaceName,
8695
role: row.role,
87-
subscribed: formatDate(row.subscribed),
96+
black: formatDate(row.black),
97+
lite: formatDate(row.lite),
8898
})),
8999
),
90100
)
@@ -151,13 +161,14 @@ async function printWorkspace(workspaceID: string) {
151161
balance: BillingTable.balance,
152162
customerID: BillingTable.customerID,
153163
reload: BillingTable.reload,
154-
subscriptionID: BillingTable.subscriptionID,
155-
subscription: {
164+
blackSubscriptionID: BillingTable.subscriptionID,
165+
blackSubscription: {
156166
plan: BillingTable.subscriptionPlan,
157167
booked: BillingTable.timeSubscriptionBooked,
158168
enrichment: BillingTable.subscription,
159169
},
160-
timeSubscriptionSelected: BillingTable.timeSubscriptionSelected,
170+
timeBlackSubscriptionSelected: BillingTable.timeSubscriptionSelected,
171+
liteSubscriptionID: BillingTable.liteSubscriptionID,
161172
})
162173
.from(BillingTable)
163174
.where(eq(BillingTable.workspaceID, workspace.id))
@@ -167,16 +178,21 @@ async function printWorkspace(workspaceID: string) {
167178
balance: `$${(row.balance / 100000000).toFixed(2)}`,
168179
reload: row.reload ? "yes" : "no",
169180
customerID: row.customerID,
170-
subscriptionID: row.subscriptionID,
171-
subscription: row.subscriptionID
181+
liteSubscriptionID: row.liteSubscriptionID,
182+
blackSubscriptionID: row.blackSubscriptionID,
183+
blackSubscription: row.blackSubscriptionID
172184
? [
173-
`Black ${row.subscription.enrichment!.plan}`,
174-
row.subscription.enrichment!.seats > 1 ? `X ${row.subscription.enrichment!.seats} seats` : "",
175-
row.subscription.enrichment!.coupon ? `(coupon: ${row.subscription.enrichment!.coupon})` : "",
176-
`(ref: ${row.subscriptionID})`,
185+
`Black ${row.blackSubscription.enrichment!.plan}`,
186+
row.blackSubscription.enrichment!.seats > 1
187+
? `X ${row.blackSubscription.enrichment!.seats} seats`
188+
: "",
189+
row.blackSubscription.enrichment!.coupon
190+
? `(coupon: ${row.blackSubscription.enrichment!.coupon})`
191+
: "",
192+
`(ref: ${row.blackSubscriptionID})`,
177193
].join(" ")
178-
: row.subscription.booked
179-
? `Waitlist ${row.subscription.plan} plan${row.timeSubscriptionSelected ? " (selected)" : ""}`
194+
: row.blackSubscription.booked
195+
? `Waitlist ${row.blackSubscription.plan} plan${row.timeBlackSubscriptionSelected ? " (selected)" : ""}`
180196
: undefined,
181197
}))[0],
182198
),

0 commit comments

Comments
 (0)