mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
address comments from coderabbit.
This commit is contained in:
@@ -256,24 +256,24 @@ function seededRandom(seed: number) {
|
||||
return x - Math.floor(x);
|
||||
}
|
||||
|
||||
const BASE_TIME_MS = Date.now();
|
||||
|
||||
export function generateFakeBarChartData(seed = 1) {
|
||||
const fakeData: [number, number][] = [];
|
||||
const now = Date.now();
|
||||
for (let i = 23; i >= 0; i--) {
|
||||
const val = seededRandom(seed + i) * 1_000_000;
|
||||
fakeData.push([now - i * 60 * 60 * 1000, Math.round(val)]);
|
||||
fakeData.push([BASE_TIME_MS - i * 60 * 60 * 1000, Math.round(val)]);
|
||||
}
|
||||
return fakeData;
|
||||
}
|
||||
|
||||
export function generateFakeLineChartData(seed = 2) {
|
||||
const fakeData: [number, number][] = [];
|
||||
const now = Date.now();
|
||||
let value = seededRandom(seed) * 5000 + 5000;
|
||||
for (let i = 23; i >= 0; i--) {
|
||||
value += (seededRandom(seed + i) - 0.5) * 1000;
|
||||
value = Math.max(0, value);
|
||||
fakeData.push([now - i * 60 * 60 * 1000, Math.round(value)]);
|
||||
fakeData.push([BASE_TIME_MS - i * 60 * 60 * 1000, Math.round(value)]);
|
||||
}
|
||||
return fakeData;
|
||||
}
|
||||
|
||||
@@ -83,15 +83,24 @@
|
||||
|
||||
<ActionMenu.Root width="fit-content" slot="tooltip" let:toggle>
|
||||
<ActionMenu.Item.Button
|
||||
on:click={(event) => toggle(event) && dispatch('change', '24h')}>
|
||||
on:click={(event) => {
|
||||
toggle(event);
|
||||
dispatch('change', '24h');
|
||||
}}>
|
||||
24h
|
||||
</ActionMenu.Item.Button>
|
||||
<ActionMenu.Item.Button
|
||||
on:click={(event) => toggle(event) && dispatch('change', '30d')}>
|
||||
on:click={(event) => {
|
||||
toggle(event);
|
||||
dispatch('change', '30d');
|
||||
}}>
|
||||
30d
|
||||
</ActionMenu.Item.Button>
|
||||
<ActionMenu.Item.Button
|
||||
on:click={(event) => toggle(event) && dispatch('change', '90d')}>
|
||||
on:click={(event) => {
|
||||
toggle(event);
|
||||
dispatch('change', '90d');
|
||||
}}>
|
||||
90d
|
||||
</ActionMenu.Item.Button>
|
||||
</ActionMenu.Root>
|
||||
|
||||
@@ -84,14 +84,20 @@
|
||||
|
||||
<ActionMenu.Root width="fit-content" slot="tooltip" let:toggle>
|
||||
<ActionMenu.Item.Button
|
||||
on:click={(event) => toggle(event) && dispatch('change', '24h')}
|
||||
>24h</ActionMenu.Item.Button>
|
||||
on:click={(event) => {
|
||||
toggle(event);
|
||||
dispatch('change', '24h');
|
||||
}}>24h</ActionMenu.Item.Button>
|
||||
<ActionMenu.Item.Button
|
||||
on:click={(event) => toggle(event) && dispatch('change', '30d')}
|
||||
>30d</ActionMenu.Item.Button>
|
||||
on:click={(event) => {
|
||||
toggle(event);
|
||||
dispatch('change', '30d');
|
||||
}}>30d</ActionMenu.Item.Button>
|
||||
<ActionMenu.Item.Button
|
||||
on:click={(event) => toggle(event) && dispatch('change', '90d')}
|
||||
>90d</ActionMenu.Item.Button>
|
||||
on:click={(event) => {
|
||||
toggle(event);
|
||||
dispatch('change', '90d');
|
||||
}}>90d</ActionMenu.Item.Button>
|
||||
</ActionMenu.Root>
|
||||
</Popover>
|
||||
</Layout.Stack>
|
||||
|
||||
@@ -22,7 +22,13 @@ export const usage = cachedStore<
|
||||
return {
|
||||
load: async (start, end, period) => {
|
||||
const currentData = get(usage);
|
||||
const currentParamsHash = hash([page.params.project, start, end, period.toString()]);
|
||||
const currentParamsHash = hash([
|
||||
page.params.project,
|
||||
page.params.region,
|
||||
start,
|
||||
end,
|
||||
period.toString()
|
||||
]);
|
||||
|
||||
// don't hit the API call if we have the data!
|
||||
if (lastParamsHash === currentParamsHash && currentData && !isDev) {
|
||||
|
||||
Reference in New Issue
Block a user