MCPcopy
hub / github.com/simstudioai/sim / getOrgMemberRefreshBounds

Function getOrgMemberRefreshBounds

apps/sim/lib/billing/credits/daily-refresh.ts:158–179  ·  view source on GitHub ↗
(
  organizationId: string,
  periodStart: Date,
  executor: DbClient = db
)

Source from the content-addressed store, hash-verified

156}
157
158export async function getOrgMemberRefreshBounds(
159 organizationId: string,
160 periodStart: Date,
161 executor: DbClient = db
162): Promise<Record<string, { userStart: Date }>> {
163 const rows = await executor
164 .select({
165 userId: member.userId,
166 snapshotAt: userStats.proPeriodCostSnapshotAt,
167 })
168 .from(member)
169 .leftJoin(userStats, eq(member.userId, userStats.userId))
170 .where(eq(member.organizationId, organizationId))
171
172 const bounds: Record<string, { userStart: Date }> = {}
173 for (const row of rows) {
174 if (row.snapshotAt && row.snapshotAt > periodStart) {
175 bounds[row.userId] = { userStart: row.snapshotAt }
176 }
177 }
178 return bounds
179}

Callers 6

computeOrgOverageAmountFunction · 0.90
getUserUsageDataFunction · 0.90
applyOrgRefreshFunction · 0.90

Calls 1

eqFunction · 0.50

Tested by

no test coverage detected