MCPcopy Index your code
hub / github.com/simstudioai/sim / ensureUserStatsExists

Function ensureUserStatsExists

apps/sim/lib/billing/core/usage.ts:173–183  ·  view source on GitHub ↗
(userId: string)

Source from the content-addressed store, hash-verified

171 * Always writes to the primary — never takes a read-routing executor.
172 */
173export async function ensureUserStatsExists(userId: string): Promise<void> {
174 await db
175 .insert(userStats)
176 .values({
177 id: generateId(),
178 userId: userId,
179 currentUsageLimit: getFreeTierLimit().toString(),
180 usageLimitUpdatedAt: new Date(),
181 })
182 .onConflictDoNothing({ target: userStats.userId })
183}
184
185/**
186 * Get comprehensive usage data for a user

Callers 2

auth.tsFile · 0.85
getUserUsageDataFunction · 0.85

Calls 3

generateIdFunction · 0.90
getFreeTierLimitFunction · 0.90
toStringMethod · 0.45

Tested by

no test coverage detected