diff --git a/bun.lock b/bun.lock index 8db6da9fae..664450fbeb 100644 --- a/bun.lock +++ b/bun.lock @@ -94,7 +94,7 @@ "cookie": "^0.7.0", "devalue": "^5.8.1", "flatted": "^3.4.2", - "immutable": "^5.1.5", + "immutable": "^5.1.8", "js-yaml": "^4.3.0", "minimatch": "10.2.3", "picomatch": "^4.0.4", @@ -959,7 +959,7 @@ "ignore": ["ignore@6.0.2", "", {}, "sha512-InwqeHHN2XpumIkMvpl/DCJVrAHgCsG5+cn1XlnLWGwtZBm8QJfSusItfrwx81CTp5agNZqpKU2J/ccC5nGT4A=="], - "immutable": ["immutable@5.1.5", "", {}, "sha512-t7xcm2siw+hlUM68I+UEOK+z84RzmN59as9DZ7P1l0994DKUWV7UXBMQZVxaoMSRQ+PBZbHCOoBt7a2wxOMt+A=="], + "immutable": ["immutable@5.1.9", "", {}, "sha512-m8nVez3rwrgmWxtLMt1ZYXB2Lv7OKYn/disyxAlSDYAlKSlFoPPfIAmAM/M5xqL4m4C/wAPw7S2/CNaUii1Hxg=="], "import-fresh": ["import-fresh@3.3.1", "", { "dependencies": { "parent-module": "^1.0.0", "resolve-from": "^4.0.0" } }, "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ=="], diff --git a/package.json b/package.json index ccde1e9adc..38942e9616 100644 --- a/package.json +++ b/package.json @@ -106,7 +106,7 @@ "minimatch": "10.2.3", "brace-expansion": ">=5.0.7", "js-yaml": "^4.3.0", - "immutable": "^5.1.5", + "immutable": "^5.1.8", "flatted": "^3.4.2", "devalue": "^5.8.1", "yaml": "^1.10.3", 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 74eab79add..d922137577 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} - - -