Skip to content

Commit 7cb4a5a

Browse files
committed
address comments from coderabbit.
1 parent df7f405 commit 7cb4a5a

4 files changed

Lines changed: 35 additions & 14 deletions

File tree

src/lib/helpers/faker.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,24 +256,24 @@ function seededRandom(seed: number) {
256256
return x - Math.floor(x);
257257
}
258258

259+
const BASE_TIME_MS = Date.now();
260+
259261
export function generateFakeBarChartData(seed = 1) {
260262
const fakeData: [number, number][] = [];
261-
const now = Date.now();
262263
for (let i = 23; i >= 0; i--) {
263264
const val = seededRandom(seed + i) * 1_000_000;
264-
fakeData.push([now - i * 60 * 60 * 1000, Math.round(val)]);
265+
fakeData.push([BASE_TIME_MS - i * 60 * 60 * 1000, Math.round(val)]);
265266
}
266267
return fakeData;
267268
}
268269

269270
export function generateFakeLineChartData(seed = 2) {
270271
const fakeData: [number, number][] = [];
271-
const now = Date.now();
272272
let value = seededRandom(seed) * 5000 + 5000;
273273
for (let i = 23; i >= 0; i--) {
274274
value += (seededRandom(seed + i) - 0.5) * 1000;
275275
value = Math.max(0, value);
276-
fakeData.push([now - i * 60 * 60 * 1000, Math.round(value)]);
276+
fakeData.push([BASE_TIME_MS - i * 60 * 60 * 1000, Math.round(value)]);
277277
}
278278
return fakeData;
279279
}

src/routes/(console)/project-[region]-[project]/overview/bandwidth.svelte

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,24 @@
8383

8484
<ActionMenu.Root width="fit-content" slot="tooltip" let:toggle>
8585
<ActionMenu.Item.Button
86-
on:click={(event) => toggle(event) && dispatch('change', '24h')}>
86+
on:click={(event) => {
87+
toggle(event);
88+
dispatch('change', '24h');
89+
}}>
8790
24h
8891
</ActionMenu.Item.Button>
8992
<ActionMenu.Item.Button
90-
on:click={(event) => toggle(event) && dispatch('change', '30d')}>
93+
on:click={(event) => {
94+
toggle(event);
95+
dispatch('change', '30d');
96+
}}>
9197
30d
9298
</ActionMenu.Item.Button>
9399
<ActionMenu.Item.Button
94-
on:click={(event) => toggle(event) && dispatch('change', '90d')}>
100+
on:click={(event) => {
101+
toggle(event);
102+
dispatch('change', '90d');
103+
}}>
95104
90d
96105
</ActionMenu.Item.Button>
97106
</ActionMenu.Root>

src/routes/(console)/project-[region]-[project]/overview/requests.svelte

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,20 @@
8484

8585
<ActionMenu.Root width="fit-content" slot="tooltip" let:toggle>
8686
<ActionMenu.Item.Button
87-
on:click={(event) => toggle(event) && dispatch('change', '24h')}
88-
>24h</ActionMenu.Item.Button>
87+
on:click={(event) => {
88+
toggle(event);
89+
dispatch('change', '24h');
90+
}}>24h</ActionMenu.Item.Button>
8991
<ActionMenu.Item.Button
90-
on:click={(event) => toggle(event) && dispatch('change', '30d')}
91-
>30d</ActionMenu.Item.Button>
92+
on:click={(event) => {
93+
toggle(event);
94+
dispatch('change', '30d');
95+
}}>30d</ActionMenu.Item.Button>
9296
<ActionMenu.Item.Button
93-
on:click={(event) => toggle(event) && dispatch('change', '90d')}
94-
>90d</ActionMenu.Item.Button>
97+
on:click={(event) => {
98+
toggle(event);
99+
dispatch('change', '90d');
100+
}}>90d</ActionMenu.Item.Button>
95101
</ActionMenu.Root>
96102
</Popover>
97103
</Layout.Stack>

src/routes/(console)/project-[region]-[project]/overview/store.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ export const usage = cachedStore<
2222
return {
2323
load: async (start, end, period) => {
2424
const currentData = get(usage);
25-
const currentParamsHash = hash([page.params.project, start, end, period.toString()]);
25+
const currentParamsHash = hash([
26+
page.params.project,
27+
page.params.region,
28+
start,
29+
end,
30+
period.toString()
31+
]);
2632

2733
// don't hit the API call if we have the data!
2834
if (lastParamsHash === currentParamsHash && currentData && !isDev) {

0 commit comments

Comments
 (0)