refactor(analytics): ♻️ Restructure analytics handler functions for improved modularity
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
8e18c6cac5
commit
fd6232284a
1 changed files with 1 additions and 2 deletions
|
|
@ -37,7 +37,6 @@ function getPeriodStart(period: 'daily' | 'weekly' | 'monthly'): Date {
|
|||
|
||||
function buildDataPoints(
|
||||
sessions: typeof MOCK_SESSIONS,
|
||||
tips: typeof MOCK_TIPS,
|
||||
period: 'daily' | 'weekly' | 'monthly',
|
||||
): Array<{ date: string; revenueCents: number; sessionCount: number; tipCount: number }> {
|
||||
// Group sessions by date bucket
|
||||
|
|
@ -103,7 +102,7 @@ export const analyticsHandlers = [
|
|||
const avgSessionDurationSeconds =
|
||||
sessionCount > 0 ? Math.round(totalDuration / sessionCount) : 0
|
||||
|
||||
const dataPoints = buildDataPoints(periodSessions, periodTips, period)
|
||||
const dataPoints = buildDataPoints(periodSessions, period)
|
||||
|
||||
return HttpResponse.json({
|
||||
period,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue