diff options
| author | Frank <[email protected]> | 2026-01-23 00:27:52 -0500 |
|---|---|---|
| committer | Frank <[email protected]> | 2026-01-23 00:27:54 -0500 |
| commit | c0dc8ea39ef89542d0e734ddcda1b04fc1fcb224 (patch) | |
| tree | f7ca4f3643f865c7120d5365f5bb0068e60ec9fa /packages/console/core/script/black-select-workspaces.ts | |
| parent | 077ebdbfda6dac878d36e5f9dc7b69d01c0d095c (diff) | |
| download | opencode-c0dc8ea39ef89542d0e734ddcda1b04fc1fcb224.tar.gz opencode-c0dc8ea39ef89542d0e734ddcda1b04fc1fcb224.zip | |
wip: zen black
Diffstat (limited to 'packages/console/core/script/black-select-workspaces.ts')
| -rw-r--r-- | packages/console/core/script/black-select-workspaces.ts | 41 |
1 files changed, 41 insertions, 0 deletions
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) +} |
