mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
fix: display 0 instead of negative usage values
This commit is contained in:
1 parent
d81d1665c1
commit
67960922d0
6 files changed
+55
-29
No files matched your search
@@ -119,7 +119,7 @@
|
||||
<Card>
|
||||
{#if count}
|
||||
<Layout.Stack gap="xs">
|
||||
<Typography.Title>{formatNumberWithCommas(total)}</Typography.Title>
|
||||
<Typography.Title>{formatNumberWithCommas(Math.max(0, total))}</Typography.Title>
|
||||
<Typography.Text>{countMetadata.title}</Typography.Text>
|
||||
</Layout.Stack>
|
||||
<div class="chart-container">
|
||||
|
||||
@@ -41,7 +41,10 @@
|
||||
|
||||
<Card>
|
||||
{#if count}
|
||||
{@const totalCount = total.reduce((a, b) => a + b, 0)}
|
||||
{@const totalCount = Math.max(
|
||||
0,
|
||||
total.reduce((a, b) => a + b, 0)
|
||||
)}
|
||||
|
||||
<Layout.Stack gap="xs">
|
||||
<Typography.Title>{formatNumberWithCommas(totalCount)}</Typography.Title>
|
||||
|
||||
@@ -445,24 +445,31 @@
|
||||
<svelte:fragment slot="aside">
|
||||
{#if data.organizationUsage.storageTotal}
|
||||
{@const totalGbHours = mbSecondsToGBHours(
|
||||
data.organizationUsage.executionsMBSecondsTotal +
|
||||
data.organizationUsage.buildsMBSecondsTotal
|
||||
Math.max(
|
||||
0,
|
||||
data.organizationUsage.executionsMBSecondsTotal +
|
||||
data.organizationUsage.buildsMBSecondsTotal
|
||||
)
|
||||
)}
|
||||
{@const progressBarStorageDate = [
|
||||
{
|
||||
size: mbSecondsToGBHours(data.organizationUsage.executionsMBSecondsTotal),
|
||||
size: mbSecondsToGBHours(
|
||||
Math.max(0, data.organizationUsage.executionsMBSecondsTotal)
|
||||
),
|
||||
color: '#85DBD8',
|
||||
tooltip: {
|
||||
title: 'Executions',
|
||||
label: `${(Math.round(mbSecondsToGBHours(data.organizationUsage.executionsMBSecondsTotal) * 100) / 100).toLocaleString('en-US')} GB hours`
|
||||
label: `${(Math.round(mbSecondsToGBHours(Math.max(0, data.organizationUsage.executionsMBSecondsTotal)) * 100) / 100).toLocaleString('en-US')} GB hours`
|
||||
}
|
||||
},
|
||||
{
|
||||
size: mbSecondsToGBHours(data.organizationUsage.buildsMBSecondsTotal),
|
||||
size: mbSecondsToGBHours(
|
||||
Math.max(0, data.organizationUsage.buildsMBSecondsTotal)
|
||||
),
|
||||
color: '#FE9567',
|
||||
tooltip: {
|
||||
title: 'Deployments',
|
||||
label: `${(Math.round(mbSecondsToGBHours(data.organizationUsage.buildsMBSecondsTotal) * 100) / 100).toLocaleString('en-US')} GB hours`
|
||||
label: `${(Math.round(mbSecondsToGBHours(Math.max(0, data.organizationUsage.buildsMBSecondsTotal)) * 100) / 100).toLocaleString('en-US')} GB hours`
|
||||
}
|
||||
}
|
||||
]}
|
||||
@@ -505,7 +512,9 @@
|
||||
<Layout.Stack direction="row">
|
||||
<Layout.Stack gap="s" direction="row" alignItems="baseline">
|
||||
<Typography.Title>
|
||||
{formatNumberWithCommas(data.organizationUsage.authPhoneTotal)}
|
||||
{formatNumberWithCommas(
|
||||
Math.max(0, data.organizationUsage.authPhoneTotal)
|
||||
)}
|
||||
</Typography.Title>
|
||||
<Typography.Text>OTPs</Typography.Text>
|
||||
</Layout.Stack>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
export function totalMetrics(set: Array<unknown>): number {
|
||||
if (!set) return 0;
|
||||
return total((set as Metric[]).map((c) => c.value));
|
||||
return Math.max(0, total((set as Metric[]).map((c) => c.value)));
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
<Container overlapCover>
|
||||
<Layout.Stack gap="xxl">
|
||||
{#if $usage}
|
||||
{@const storage = humanFileSize($usage.filesStorageTotal ?? 0)}
|
||||
{@const storage = humanFileSize(Math.max(0, $usage.filesStorageTotal ?? 0))}
|
||||
<Layout.Stack gap="xl">
|
||||
<Layout.Stack gap="l" direction={$isSmallViewport ? 'column' : 'row'}>
|
||||
<Card.Base
|
||||
@@ -132,7 +132,7 @@
|
||||
|
||||
<div class="grid-item-1-end-start">
|
||||
<Typography.Title>
|
||||
{formatNum($usage.documentsTotal ?? 0)}
|
||||
{formatNum(Math.max(0, $usage.documentsTotal ?? 0))}
|
||||
</Typography.Title>
|
||||
<Typography.Text>Rows</Typography.Text>
|
||||
</div>
|
||||
@@ -177,7 +177,7 @@
|
||||
|
||||
<div class="grid-item-1-end-start">
|
||||
<Typography.Title>
|
||||
{formatNum($usage.usersTotal ?? 0)}
|
||||
{formatNum(Math.max(0, $usage.usersTotal ?? 0))}
|
||||
</Typography.Title>
|
||||
<Typography.Text>Users</Typography.Text>
|
||||
</div>
|
||||
@@ -199,7 +199,7 @@
|
||||
|
||||
<div class="grid-item-1-end-start">
|
||||
<Typography.Title>
|
||||
{formatNum($usage.executionsTotal ?? 0)}
|
||||
{formatNum(Math.max(0, $usage.executionsTotal ?? 0))}
|
||||
</Typography.Title>
|
||||
<Typography.Text>Executions</Typography.Text>
|
||||
</div>
|
||||
|
||||
+25
-14
@@ -24,10 +24,12 @@
|
||||
$: usersTotal = data.usage.usersTotal;
|
||||
$: executions = data.usage.executions;
|
||||
$: executionsTotal = data.usage.executionsTotal;
|
||||
$: storage =
|
||||
$: storage = Math.max(
|
||||
0,
|
||||
data.usage.filesStorageTotal +
|
||||
data.usage.deploymentsStorageTotal +
|
||||
data.usage.buildsStorageTotal;
|
||||
data.usage.deploymentsStorageTotal +
|
||||
data.usage.buildsStorageTotal
|
||||
);
|
||||
$: imageTransformations = data.usage.imageTransformations;
|
||||
$: imageTransformationsTotal = data.usage.imageTransformationsTotal;
|
||||
$: dbReads = data.usage.databasesReads;
|
||||
@@ -36,11 +38,17 @@
|
||||
$: legendData = [
|
||||
{
|
||||
name: 'Reads',
|
||||
value: data.usage.databasesReads.reduce((sum, item) => sum + item.value, 0)
|
||||
value: Math.max(
|
||||
0,
|
||||
data.usage.databasesReads.reduce((sum, item) => sum + item.value, 0)
|
||||
)
|
||||
},
|
||||
{
|
||||
name: 'Writes',
|
||||
value: data.usage.databasesWrites.reduce((sum, item) => sum + item.value, 0)
|
||||
value: Math.max(
|
||||
0,
|
||||
data.usage.databasesWrites.reduce((sum, item) => sum + item.value, 0)
|
||||
)
|
||||
}
|
||||
];
|
||||
|
||||
@@ -132,7 +140,7 @@
|
||||
Total user in your project.
|
||||
<svelte:fragment slot="aside">
|
||||
{#if users}
|
||||
{@const current = formatNum(usersTotal)}
|
||||
{@const current = formatNum(Math.max(0, usersTotal))}
|
||||
<Layout.Stack gap="s" direction="row" alignItems="baseline">
|
||||
<Typography.Title>
|
||||
{current}
|
||||
@@ -208,7 +216,7 @@
|
||||
Total unique image transformations in your project.
|
||||
<svelte:fragment slot="aside">
|
||||
{#if imageTransformations}
|
||||
{@const current = formatNum(imageTransformationsTotal)}
|
||||
{@const current = formatNum(Math.max(0, imageTransformationsTotal))}
|
||||
<div class="u-flex u-flex-vertical">
|
||||
<div class="u-flex u-main-space-between">
|
||||
<p>
|
||||
@@ -246,7 +254,7 @@
|
||||
Calculated for all functions that are executed in this project.
|
||||
<svelte:fragment slot="aside">
|
||||
{#if executions}
|
||||
{@const current = formatNum(executionsTotal)}
|
||||
{@const current = formatNum(Math.max(0, executionsTotal))}
|
||||
<Layout.Stack gap="s" direction="row" alignItems="baseline">
|
||||
<Typography.Title>
|
||||
{current}
|
||||
@@ -356,23 +364,26 @@
|
||||
<svelte:fragment slot="aside">
|
||||
{#if data.usage.executionsMbSecondsTotal}
|
||||
{@const totalGbHours = mbSecondsToGBHours(
|
||||
data.usage.executionsMbSecondsTotal + data.usage.buildsMbSecondsTotal
|
||||
Math.max(
|
||||
0,
|
||||
data.usage.executionsMbSecondsTotal + data.usage.buildsMbSecondsTotal
|
||||
)
|
||||
)}
|
||||
{@const progressBarStorageDate = [
|
||||
{
|
||||
size: mbSecondsToGBHours(data.usage.executionsMbSecondsTotal),
|
||||
size: mbSecondsToGBHours(Math.max(0, data.usage.executionsMbSecondsTotal)),
|
||||
color: '#85DBD8',
|
||||
tooltip: {
|
||||
title: 'Executions',
|
||||
label: `${(Math.round(mbSecondsToGBHours(data.usage.executionsMbSecondsTotal) * 100) / 100).toLocaleString('en-US')} GB hours`
|
||||
label: `${(Math.round(mbSecondsToGBHours(Math.max(0, data.usage.executionsMbSecondsTotal)) * 100) / 100).toLocaleString('en-US')} GB hours`
|
||||
}
|
||||
},
|
||||
{
|
||||
size: mbSecondsToGBHours(data.usage.buildsMbSecondsTotal),
|
||||
size: mbSecondsToGBHours(Math.max(0, data.usage.buildsMbSecondsTotal)),
|
||||
color: '#FE9567',
|
||||
tooltip: {
|
||||
title: 'Deployments',
|
||||
label: `${(Math.round(mbSecondsToGBHours(data.usage.buildsMbSecondsTotal) * 100) / 100).toLocaleString('en-US')} GB hours`
|
||||
label: `${(Math.round(mbSecondsToGBHours(Math.max(0, data.usage.buildsMbSecondsTotal)) * 100) / 100).toLocaleString('en-US')} GB hours`
|
||||
}
|
||||
}
|
||||
]}
|
||||
@@ -405,7 +416,7 @@
|
||||
<div class="u-flex u-main-space-between">
|
||||
<Layout.Stack gap="s" direction="row" alignItems="baseline">
|
||||
<Typography.Title>
|
||||
{formatNumberWithCommas(data.usage.authPhoneTotal)}
|
||||
{formatNumberWithCommas(Math.max(0, data.usage.authPhoneTotal))}
|
||||
</Typography.Title>
|
||||
<Typography.Text>OTPs</Typography.Text>
|
||||
</Layout.Stack>
|
||||
|
||||
+4
-1
@@ -84,7 +84,10 @@
|
||||
|
||||
metric.value = time !== '0s' ? time : '-';
|
||||
} else {
|
||||
metric.value = usage[metric.id] ?? '-';
|
||||
metric.value =
|
||||
usage[metric.id] !== undefined
|
||||
? Math.max(0, usage[metric.id]).toString()
|
||||
: '-';
|
||||
}
|
||||
return metric;
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user