Skip to content

Commit 4dca91f

Browse files
committed
fix: 🐛 improves storage calculation accuracy
1 parent 4fb1b84 commit 4dca91f

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

Components/UI/StorageBar/StorageBar.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import classes from './StorageBar.module.css';
33

44
export default function StorageBar(props) {
55
//Var
6-
//storageUsed is in octet, storageSize is in GB. Round to 1 decimal for %.
7-
const storageUsedPercent = (((props.storageUsed / 1000000) * 100) / props.storageSize).toFixed(1);
6+
//storageUsed is in kB, storageSize is in GB. Round to 1 decimal for %.
7+
const storageUsedPercent = (((props.storageUsed / 1024 ** 2) * 100) / props.storageSize).toFixed(
8+
1
9+
);
810

911
return (
1012
<div className={classes.barContainer}>
@@ -19,8 +21,8 @@ export default function StorageBar(props) {
1921
<div className={classes.progressionStyle} />
2022
</div>
2123
<div className={classes.tooltip}>
22-
{storageUsedPercent}% ({(props.storageUsed / 1000000).toFixed(1)} GB / {props.storageSize}{' '}
23-
GB)
24+
{storageUsedPercent}% ({(props.storageUsed / 1024 ** 2).toFixed(1)} GB /{' '}
25+
{props.storageSize} GB)
2426
</div>
2527
</div>
2628
</div>

Containers/Monitoring/StorageUsedChartBar/StorageUsedChartBar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ export default function StorageUsedChartBar() {
7171
datasets: [
7272
{
7373
label: 'Storage used (%)',
74-
//storageUsed is in octet, storageSize is in GB. Round to 1 decimal for %.
74+
//storageUsed is in kB, storageSize is in GB. Round to 1 decimal for %.
7575
data: data.map((repo) =>
76-
(((repo.storageUsed / 1000000) * 100) / repo.storageSize).toFixed(1)
76+
(((repo.storageUsed / 1024 ** 2) * 100) / repo.storageSize).toFixed(1)
7777
),
7878
backgroundColor: '#704dff',
7979
},

0 commit comments

Comments
 (0)