mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
fix(sites): remove deployment metrics card calling sites.getUsage()
sites.getUsage() is being dropped from the SDK (appwrite/sdk-for-console#105), along with the other usage endpoints removed in #3134. This inline build-metrics card on the site deployments page was the one live consumer that cleanup missed.
This commit is contained in:
1 parent
a2a7e1a93b
commit
3924835e96
2 files changed
-137
No files matched your search
-3
@@ -10,7 +10,6 @@
|
||||
import CreateGitDeploymentModal from './createGitDeploymentModal.svelte';
|
||||
import { columns } from './store';
|
||||
import CreateManualDeploymentModal from './createManualDeploymentModal.svelte';
|
||||
import DeploymentMetrics from './deploymentMetrics.svelte';
|
||||
import { IconPlus } from '@appwrite.io/pink-icons-svelte';
|
||||
import { onMount } from 'svelte';
|
||||
import { realtime, sdk } from '$lib/stores/sdk';
|
||||
@@ -123,8 +122,6 @@
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
<DeploymentMetrics />
|
||||
|
||||
<Layout.Stack gap="l">
|
||||
<ResponsiveContainerHeader
|
||||
view={View.Table}
|
||||
|
||||
-134
@@ -1,134 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { InputSelect } from '$lib/elements/forms';
|
||||
import { toLocaleDate } from '$lib/helpers/date';
|
||||
import { Layout, Typography } from '@appwrite.io/pink-svelte';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { UsageRange } from '@appwrite.io/console';
|
||||
import { onMount } from 'svelte';
|
||||
import { page } from '$app/state';
|
||||
import { UsageCard } from '$lib/components';
|
||||
import { humanFileSize } from '$lib/helpers/sizeConvertion';
|
||||
import { formatTimeDetailed } from '$lib/helpers/timeConversion';
|
||||
import { clampMin } from '$lib/helpers/numbers';
|
||||
|
||||
const now = new Date();
|
||||
const rangeOptions = [
|
||||
{ value: UsageRange.TwentyFourHours, label: 'Last 24 hours' },
|
||||
{ value: UsageRange.ThirtyDays, label: 'Last 30 days' },
|
||||
{ value: UsageRange.NinetyDays, label: 'Last 90 days' }
|
||||
];
|
||||
|
||||
let range = UsageRange.ThirtyDays;
|
||||
let metrics: { id: string; value: string | null; description: string }[] = [
|
||||
{
|
||||
id: 'buildsTotal',
|
||||
value: null,
|
||||
description: 'Total builds count'
|
||||
},
|
||||
{
|
||||
id: 'buildsStorageTotal',
|
||||
value: null,
|
||||
description: 'Total builds size'
|
||||
},
|
||||
{
|
||||
id: 'buildsTimeTotal',
|
||||
value: null,
|
||||
description: 'Total builds time'
|
||||
},
|
||||
{
|
||||
id: 'buildsTimeAverage',
|
||||
value: null,
|
||||
description: 'Avg. builds time'
|
||||
},
|
||||
{
|
||||
id: 'buildsSuccessTotal',
|
||||
value: null,
|
||||
description: 'Successful'
|
||||
},
|
||||
{
|
||||
id: 'buildsFailedTotal',
|
||||
value: null,
|
||||
description: 'Failed '
|
||||
}
|
||||
];
|
||||
onMount(async () => {
|
||||
await fetchUsage();
|
||||
});
|
||||
|
||||
async function fetchUsage() {
|
||||
metrics = metrics.map((metric) => {
|
||||
metric.value = null;
|
||||
|
||||
return metric;
|
||||
});
|
||||
|
||||
// Add timeout to make it look nicer
|
||||
setTimeout(async () => {
|
||||
try {
|
||||
const usage = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.sites.getUsage({
|
||||
siteId: page.params.site,
|
||||
range
|
||||
});
|
||||
metrics = metrics.map((metric) => {
|
||||
if (metric.id === 'buildsStorageTotal') {
|
||||
const size = humanFileSize(usage[metric.id]);
|
||||
|
||||
metric.value = parseInt(size?.value) > 0 ? size.value + size.unit : '-';
|
||||
} else if (
|
||||
metric.id === 'buildsTimeTotal' ||
|
||||
metric.id === 'buildsTimeAverage'
|
||||
) {
|
||||
const seconds = usage[metric.id] > 0 ? usage[metric.id] / 1000 : 0;
|
||||
const time = formatTimeDetailed(seconds);
|
||||
|
||||
metric.value = time !== '0s' ? time : '-';
|
||||
} else {
|
||||
metric.value =
|
||||
usage[metric.id] !== undefined
|
||||
? clampMin(usage[metric.id]).toString()
|
||||
: '-';
|
||||
}
|
||||
return metric;
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
</script>
|
||||
|
||||
<Layout.Stack gap="xl">
|
||||
<Layout.Stack direction="row" justifyContent="space-between" alignItems="flex-end" wrap="wrap">
|
||||
<Typography.Text variant="m-400" color="--fgcolor-neutral-tertiary">
|
||||
Metrics for {range !== UsageRange.TwentyFourHours
|
||||
? `${toLocaleDate(
|
||||
new Date(
|
||||
now.getTime() - parseInt(range.split('d')[0]) * 24 * 60 * 60 * 1000
|
||||
).toString()
|
||||
)} to`
|
||||
: ''}
|
||||
{toLocaleDate(now.toString())}
|
||||
</Typography.Text>
|
||||
<div>
|
||||
<InputSelect
|
||||
id="range"
|
||||
bind:value={range}
|
||||
options={rangeOptions}
|
||||
on:change={fetchUsage} />
|
||||
</div>
|
||||
</Layout.Stack>
|
||||
<Layout.Grid gap="m" columnsL={2} columns={1}>
|
||||
<Layout.Stack direction="row" gap="m">
|
||||
{#each metrics.slice(0, 3) as metric}
|
||||
<UsageCard description={metric.description} bind:value={metric.value} />
|
||||
{/each}
|
||||
</Layout.Stack>
|
||||
<Layout.Stack direction="row" gap="m">
|
||||
{#each metrics.slice(3) as metric}
|
||||
<UsageCard description={metric.description} bind:value={metric.value} />
|
||||
{/each}
|
||||
</Layout.Stack>
|
||||
</Layout.Grid>
|
||||
</Layout.Stack>
|
||||
Reference in new issue
Block a user