MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / run

Function run

apps/web/src/scripts/usage/generate-user-data.ts:47–87  ·  view source on GitHub ↗
(...args: string[])

Source from the content-addressed store, hash-verified

45}
46
47export async function run(...args: string[]): Promise<void> {
48 const [userId, ...rest] = args;
49 assert(userId, 'User ID is required as the first argument');
50 const flags = parseFlags(rest);
51
52 const user = await db.query.kilocode_users.findFirst({
53 where: eq(kilocode_users.id, userId),
54 });
55 if (!user) {
56 throw new Error(`User ${userId} not found`);
57 }
58
59 console.log(
60 `Generating personal-scope mock usage for user: ${user.google_user_name} <${user.google_user_email}> (${userId})`
61 );
62
63 if (flags.reset) {
64 await cliConfirm(
65 `--reset will DELETE all personal-scope microdollar_usage rows for this user. Continue?`
66 );
67 const { deleted } = await deletePersonalUsageFor(userId);
68 console.log(`Deleted ${deleted} existing personal-scope microdollar_usage rows.`);
69 }
70
71 const lookups = await ensureLookupsSeeded();
72
73 const stats = await generateAndInsertMockUsage(
74 {
75 kiloUserIds: [userId],
76 organizationId: null,
77 },
78 lookups
79 );
80
81 console.log('');
82 console.log(`Done. Inserted ${stats.recordCount} usage records.`);
83 console.log('');
84 console.log(
85 'Usage Analytics reads from Snowflake; point the sandbox env at DBT_BACKEND_SANDBOX to see data.'
86 );
87}

Callers

nothing calls this directly

Calls 6

cliConfirmFunction · 0.90
deletePersonalUsageForFunction · 0.90
ensureLookupsSeededFunction · 0.90
parseFlagsFunction · 0.70
logMethod · 0.65

Tested by

no test coverage detected