summaryrefslogtreecommitdiffhomepage
path: root/packages/console/core
diff options
context:
space:
mode:
authorFrank <[email protected]>2026-01-23 00:27:52 -0500
committerFrank <[email protected]>2026-01-23 00:27:54 -0500
commitc0dc8ea39ef89542d0e734ddcda1b04fc1fcb224 (patch)
treef7ca4f3643f865c7120d5365f5bb0068e60ec9fa /packages/console/core
parent077ebdbfda6dac878d36e5f9dc7b69d01c0d095c (diff)
downloadopencode-c0dc8ea39ef89542d0e734ddcda1b04fc1fcb224.tar.gz
opencode-c0dc8ea39ef89542d0e734ddcda1b04fc1fcb224.zip
wip: zen black
Diffstat (limited to 'packages/console/core')
-rw-r--r--packages/console/core/script/black-onboard-waitlist.ts40
-rw-r--r--packages/console/core/script/black-select-workspaces.ts41
-rw-r--r--packages/console/core/script/lookup-user.ts7
3 files changed, 86 insertions, 2 deletions
diff --git a/packages/console/core/script/black-onboard-waitlist.ts b/packages/console/core/script/black-onboard-waitlist.ts
new file mode 100644
index 000000000..96d0f8f91
--- /dev/null
+++ b/packages/console/core/script/black-onboard-waitlist.ts
@@ -0,0 +1,40 @@
+import { subscribe } from "diagnostics_channel"
+import { Billing } from "../src/billing.js"
+import { and, Database, eq } from "../src/drizzle/index.js"
+import { BillingTable, PaymentTable, SubscriptionTable } from "../src/schema/billing.sql.js"
+
+const workspaceID = process.argv[2]
+
+if (!workspaceID) {
+ console.error("Usage: bun script/foo.ts <workspaceID>")
+ process.exit(1)
+}
+
+console.log(`Onboarding to Black waitlist`)
+
+const billing = await Database.use((tx) =>
+ tx
+ .select({
+ subscriptionPlan: BillingTable.subscriptionPlan,
+ timeSubscriptionBooked: BillingTable.timeSubscriptionBooked,
+ })
+ .from(BillingTable)
+ .where(eq(BillingTable.workspaceID, workspaceID))
+ .then((rows) => rows[0]),
+)
+
+if (!billing?.timeSubscriptionBooked) {
+ console.error(`Error: Workspace is not on the waitlist`)
+ process.exit(1)
+}
+
+await Database.use((tx) =>
+ tx
+ .update(BillingTable)
+ .set({
+ timeSubscriptionSelected: new Date(),
+ })
+ .where(eq(BillingTable.workspaceID, workspaceID)),
+)
+
+console.log(`Done`)
diff --git a/packages/console/core/script/black-select-workspaces.ts b/packages/console/core/script/black-select-workspaces.ts
new file mode 100644
index 000000000..4e103b7c1
--- /dev/null
+++ b/packages/console/core/script/black-select-workspaces.ts
@@ -0,0 +1,41 @@
+import { Database, eq, and, sql, inArray, isNull, count } from "../src/drizzle/index.js"
+import { BillingTable, SubscriptionPlan } from "../src/schema/billing.sql.js"
+import { UserTable } from "../src/schema/user.sql.js"
+import { AuthTable } from "../src/schema/auth.sql.js"
+
+const plan = process.argv[2] as typeof SubscriptionPlan[number]
+if (!SubscriptionPlan.includes(plan)) {
+ console.error("Usage: bun foo.ts <count>")
+ process.exit(1)
+}
+
+const workspaces = await Database.use((tx) =>
+ tx
+ .select({ workspaceID: BillingTable.workspaceID })
+ .from(BillingTable)
+ .where(and(eq(BillingTable.subscriptionPlan, plan), isNull(BillingTable.timeSubscriptionSelected)))
+ .orderBy(sql`RAND()`)
+ .limit(100),
+)
+
+console.log(`Found ${workspaces.length} workspaces on Black ${plan} waitlist`)
+
+console.log("== Workspace IDs ==")
+const ids = workspaces.map((w) => w.workspaceID)
+for (const id of ids) {
+ console.log(id)
+}
+
+console.log("\n== User Emails ==")
+const emails = await Database.use((tx) =>
+ tx
+ .select({ email: AuthTable.subject })
+ .from(UserTable)
+ .innerJoin(AuthTable, and(eq(UserTable.accountID, AuthTable.accountID), eq(AuthTable.provider, "email")))
+ .where(inArray(UserTable.workspaceID, ids)),
+)
+
+const unique = new Set(emails.map((row) => row.email))
+for (const email of unique) {
+ console.log(email)
+}
diff --git a/packages/console/core/script/lookup-user.ts b/packages/console/core/script/lookup-user.ts
index 0a614bc15..6367fd89a 100644
--- a/packages/console/core/script/lookup-user.ts
+++ b/packages/console/core/script/lookup-user.ts
@@ -129,14 +129,17 @@ async function printWorkspace(workspaceID: string) {
booked: BillingTable.timeSubscriptionBooked,
enrichment: BillingTable.subscription,
},
+ timeSubscriptionSelected: BillingTable.timeSubscriptionSelected,
})
.from(BillingTable)
.where(eq(BillingTable.workspaceID, workspace.id))
.then(
(rows) =>
rows.map((row) => ({
- ...row,
balance: `$${(row.balance / 100000000).toFixed(2)}`,
+ reload: row.reload ? "yes" : "no",
+ customerID: row.customerID,
+ subscriptionID: row.subscriptionID,
subscription: row.subscriptionID
? [
`Black ${row.subscription.enrichment!.plan}`,
@@ -145,7 +148,7 @@ async function printWorkspace(workspaceID: string) {
`(ref: ${row.subscriptionID})`,
].join(" ")
: row.subscription.booked
- ? `Waitlist ${row.subscription.plan} plan`
+ ? `Waitlist ${row.subscription.plan} plan${row.timeSubscriptionSelected ? " (selected)" : ""}`
: undefined,
}))[0],
),