Skip to content

Commit 4984c01

Browse files
committed
fix(dash): if only one time period has analytics events, show that period for summary
1 parent a3f59e5 commit 4984c01

File tree

2 files changed

+8
-2
lines changed
  • apps/dashboard/src/app/team/[team_slug]

2 files changed

+8
-2
lines changed

apps/dashboard/src/app/team/[team_slug]/(team)/~/analytics/page.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,10 @@ function UsersChartCard({
257257
}
258258
data={timeSeriesData}
259259
aggregateFn={(_data, key) =>
260-
timeSeriesData[timeSeriesData.length - 2]?.[key]
260+
// If there is only one data point, use that one, otherwise use the previous
261+
timeSeriesData.filter((d) => (d[key] as number) > 0).length >= 2
262+
? timeSeriesData[timeSeriesData.length - 2]?.[key]
263+
: timeSeriesData[timeSeriesData.length - 1]?.[key]
261264
}
262265
// Get the trend from the last two COMPLETE periods
263266
trendFn={(data, key) =>

apps/dashboard/src/app/team/[team_slug]/[project_slug]/page.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,10 @@ function UsersChartCard({
279279
queryKey="usersChart"
280280
data={timeSeriesData}
281281
aggregateFn={(_data, key) =>
282-
timeSeriesData[timeSeriesData.length - 2]?.[key]
282+
// If there is only one data point, use that one, otherwise use the previous
283+
timeSeriesData.filter((d) => (d[key] as number) > 0).length >= 2
284+
? timeSeriesData[timeSeriesData.length - 2]?.[key]
285+
: timeSeriesData[timeSeriesData.length - 1]?.[key]
283286
}
284287
// Get the trend from the last two COMPLETE periods
285288
trendFn={(data, key) =>

0 commit comments

Comments
 (0)