Skip to content

Commit 0aca563

Browse files
committed
Fix RPC usage page to handle missing peak date (#6748)
This PR adds a null check for the peak date in the RPC Usage page to handle cases where there are no requests in the last 24 hours. It displays "No Requests in last 24 hours" instead of attempting to format a non-existent date. Additionally, it destructures the `averageRate` directly from the API data to improve code readability when passing it to the RateGraph and CountGraph components.
1 parent 5463baa commit 0aca563

File tree

1 file changed

+6
-4
lines changed
  • apps/dashboard/src/app/team/[team_slug]/(team)/~/usage/rpc

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default async function RPCUsage(props: {
4545
return <div>Error fetching data, please try again later</div>;
4646
}
4747

48-
const { peakRate, totalCounts } = apiData.data;
48+
const { peakRate, totalCounts, averageRate } = apiData.data;
4949

5050
// Calculate percentage of limit for the peak
5151
const peakPercentage = (peakRate.peakRPS / currentRateLimit) * 100;
@@ -113,7 +113,9 @@ export default async function RPCUsage(props: {
113113
</div>
114114
<p className="mt-1 text-muted-foreground text-xs">
115115
<ClockIcon className="mr-1 inline h-3 w-3" />
116-
{format(new Date(peakRate.date), "MMM d, HH:mm")}
116+
{peakRate.date
117+
? format(new Date(peakRate.date), "MMM d, HH:mm")
118+
: "No Requests in last 24 hours"}
117119
</p>
118120
</CardContent>
119121
</Card>
@@ -196,13 +198,13 @@ export default async function RPCUsage(props: {
196198
<RateGraph
197199
peakPercentage={peakPercentage}
198200
currentRateLimit={currentRateLimit}
199-
data={apiData.data.averageRate}
201+
data={averageRate}
200202
/>
201203

202204
<CountGraph
203205
peakPercentage={peakPercentage}
204206
currentRateLimit={currentRateLimit}
205-
data={apiData.data.averageRate}
207+
data={averageRate}
206208
/>
207209
</div>
208210
);

0 commit comments

Comments
 (0)