Skip to content

Commit cb1fa3c

Browse files
committed
fix incorrect total savings calculation
1 parent a6e2b69 commit cb1fa3c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

packages/web/src/ee/features/analytics/analyticsContent.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,9 @@ export function AnalyticsContent() {
392392

393393
const totalSavings = useMemo(() => {
394394
if (!analyticsResponse) return 0
395-
const totalOperations = analyticsResponse.reduce((sum, row) => sum + row.code_searches + row.navigations, 0)
395+
// Only sum daily entries to avoid double-counting from overlapping time buckets
396+
const dailyEntries = analyticsResponse.filter(row => row.period === "day")
397+
const totalOperations = dailyEntries.reduce((sum, row) => sum + row.code_searches + row.navigations, 0)
396398
const totalMinutesSaved = totalOperations * numericAvgMinutesSaved
397399
const hourlyRate = numericAvgSalary / (40 * 52)
398400
return Math.round((totalMinutesSaved / 60 * hourlyRate) * 100) / 100
@@ -601,7 +603,7 @@ export function AnalyticsContent() {
601603
<p className="text-sm text-muted-foreground mb-2">Total Estimated Savings</p>
602604
<p className="text-3xl font-bold text-card-foreground">${totalSavings.toLocaleString()}</p>
603605
<p className="text-xs text-muted-foreground mt-1">
604-
Based on {analyticsResponse.reduce((sum, row) => sum + row.code_searches + row.navigations, 0).toLocaleString()} total operations
606+
Based on {dailyData.reduce((sum, row) => sum + row.code_searches + row.navigations, 0).toLocaleString()} total operations
605607
</p>
606608
</div>
607609
</CardContent>

0 commit comments

Comments
 (0)