From 3924835e9666358f18fb0c387e59ae885f7c5c0e Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Wed, 22 Jul 2026 16:13:09 +0530 Subject: [PATCH] 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. --- .../site-[site]/deployments/+page.svelte | 3 - .../deployments/deploymentMetrics.svelte | 134 ------------------ 2 files changed, 137 deletions(-) delete mode 100644 src/routes/(console)/project-[region]-[project]/sites/site-[site]/deployments/deploymentMetrics.svelte diff --git a/src/routes/(console)/project-[region]-[project]/sites/site-[site]/deployments/+page.svelte b/src/routes/(console)/project-[region]-[project]/sites/site-[site]/deployments/+page.svelte index 74eab79ad..d92213757 100644 --- a/src/routes/(console)/project-[region]-[project]/sites/site-[site]/deployments/+page.svelte +++ b/src/routes/(console)/project-[region]-[project]/sites/site-[site]/deployments/+page.svelte @@ -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} - - - 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); - } - - - - - - Metrics for {range !== UsageRange.TwentyFourHours - ? `${toLocaleDate( - new Date( - now.getTime() - parseInt(range.split('d')[0]) * 24 * 60 * 60 * 1000 - ).toString() - )} to` - : ''} - {toLocaleDate(now.toString())} - -
- -
-
- - - {#each metrics.slice(0, 3) as metric} - - {/each} - - - {#each metrics.slice(3) as metric} - - {/each} - - -