Skip to content

Commit cd77a3c

Browse files
atrakhConvex, Inc.
authored and
Convex, Inc.
committed
dashboard: fix insights period (#36497)
GitOrigin-RevId: 375ce00ea6dac6d775ee06b530cb6cc491b256c3
1 parent a1d86a9 commit cd77a3c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

npm-packages/dashboard/src/api/insights.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ export function useInsightsPeriod() {
1313
const hoursAgo72 = new Date(now.getTime() - 72 * 60 * 60 * 1000);
1414

1515
return {
16-
from: hoursAgo72.toISOString().split("T")[0],
17-
to: now.toISOString().split("T")[0],
16+
from: hoursAgo72.toISOString(),
17+
to: now.toISOString(),
1818
};
1919
}
2020

@@ -68,15 +68,14 @@ export type Insight = { functionId: string; componentPath: string | null } & (
6868
function padAndSortHourlyData(
6969
hourlyCounts: HourlyCount[],
7070
periodStart?: string,
71-
_periodEnd?: string, // This parameter is kept for backward compatibility but not used
7271
): HourlyCount[] {
7372
// Get current time to limit future data points
7473
const currentTime = new Date();
7574

7675
if (hourlyCounts.length === 0) {
7776
// If no data but we have period start, create empty data from period start to now
7877
if (periodStart) {
79-
const startDate = new Date(`${periodStart}T00:00:00Z`);
78+
const startDate = new Date(periodStart);
8079
const endDate = new Date(currentTime);
8180

8281
const result: HourlyCount[] = [];
@@ -119,7 +118,7 @@ function padAndSortHourlyData(
119118

120119
if (periodStart) {
121120
// Use the provided period start and current time as end
122-
startDate = new Date(`${periodStart}T00:00:00Z`);
121+
startDate = new Date(periodStart);
123122
endDate = new Date(currentTime);
124123
} else {
125124
// Otherwise use min/max from the data
@@ -206,7 +205,10 @@ export function useInsights(): Insight[] | undefined {
206205
const deployment = useCurrentDeployment();
207206
const common = {
208207
deploymentName: deployment?.name,
209-
period,
208+
period: {
209+
from: period.from.split("T")[0],
210+
to: period.to.split("T")[0],
211+
},
210212
teamId: team?.id!,
211213
projectId: null,
212214
componentPrefix: null,

0 commit comments

Comments
 (0)