(userId: string)
| 544 | } |
| 545 | |
| 546 | async function getPersonalUsageSnapshot(userId: string): Promise<PersonalUsageSnapshot | null> { |
| 547 | const [stats] = await db |
| 548 | .select({ |
| 549 | currentPeriodCost: userStats.currentPeriodCost, |
| 550 | proPeriodCostSnapshot: userStats.proPeriodCostSnapshot, |
| 551 | proPeriodCostSnapshotAt: userStats.proPeriodCostSnapshotAt, |
| 552 | lastPeriodCost: userStats.lastPeriodCost, |
| 553 | }) |
| 554 | .from(userStats) |
| 555 | .where(eq(userStats.userId, userId)) |
| 556 | .limit(1) |
| 557 | |
| 558 | return stats ? personalUsageSnapshotFromStats(stats) : null |
| 559 | } |
| 560 | |
| 561 | function personalUsageSnapshotFromStats(stats: { |
| 562 | currentPeriodCost: string | number | null |
no test coverage detected