mirror of
https://github.com/Ravinou/borgwarehouse
synced 2026-03-14 14:25:46 +01:00
fix: 🐛 improves storage calculation accuracy
This commit is contained in:
parent
b0fae4f59d
commit
fc3f57e24c
2 changed files with 8 additions and 6 deletions
|
|
@ -3,8 +3,10 @@ import classes from './StorageBar.module.css';
|
|||
|
||||
export default function StorageBar(props) {
|
||||
//Var
|
||||
//storageUsed is in octet, storageSize is in GB. Round to 1 decimal for %.
|
||||
const storageUsedPercent = (((props.storageUsed / 1000000) * 100) / props.storageSize).toFixed(1);
|
||||
//storageUsed is in kB, storageSize is in GB. Round to 1 decimal for %.
|
||||
const storageUsedPercent = (((props.storageUsed / 1024 ** 2) * 100) / props.storageSize).toFixed(
|
||||
1
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={classes.barContainer}>
|
||||
|
|
@ -19,8 +21,8 @@ export default function StorageBar(props) {
|
|||
<div className={classes.progressionStyle} />
|
||||
</div>
|
||||
<div className={classes.tooltip}>
|
||||
{storageUsedPercent}% ({(props.storageUsed / 1000000).toFixed(1)} GB / {props.storageSize}{' '}
|
||||
GB)
|
||||
{storageUsedPercent}% ({(props.storageUsed / 1024 ** 2).toFixed(1)} GB /{' '}
|
||||
{props.storageSize} GB)
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -71,9 +71,9 @@ export default function StorageUsedChartBar() {
|
|||
datasets: [
|
||||
{
|
||||
label: 'Storage used (%)',
|
||||
//storageUsed is in octet, storageSize is in GB. Round to 1 decimal for %.
|
||||
//storageUsed is in kB, storageSize is in GB. Round to 1 decimal for %.
|
||||
data: data.map((repo) =>
|
||||
(((repo.storageUsed / 1000000) * 100) / repo.storageSize).toFixed(1)
|
||||
(((repo.storageUsed / 1024 ** 2) * 100) / repo.storageSize).toFixed(1)
|
||||
),
|
||||
backgroundColor: '#704dff',
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue