Skip to content

Commit c10b3ff

Browse files
fix: floor disk usage values (#2253)
1 parent 5e75a0b commit c10b3ff

File tree

7 files changed

+11
-11
lines changed

7 files changed

+11
-11
lines changed

src/components/DiskStateProgressBar/DiskStateProgressBar.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export function DiskStateProgressBar({
5959
}
6060

6161
if (!compact && diskAllocatedPercent >= 0) {
62-
return <div className={b('title')}>{`${Math.round(diskAllocatedPercent)}%`}</div>;
62+
return <div className={b('title')}>{`${Math.floor(diskAllocatedPercent)}%`}</div>;
6363
}
6464

6565
return null;

src/components/MemoryViewer/MemoryViewer.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export function MemoryViewer({
5959

6060
const theme = useTheme();
6161
let fillWidth =
62-
Math.round((parseFloat(String(memoryUsage)) / parseFloat(String(capacity))) * 100) || 0;
62+
Math.floor((parseFloat(String(memoryUsage)) / parseFloat(String(capacity))) * 100) || 0;
6363
fillWidth = fillWidth > 100 ? 100 : fillWidth;
6464
let valueText: number | string | undefined = memoryUsage,
6565
capacityText: number | string | undefined = capacity,

src/components/ProgressViewer/ProgressViewer.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export function ProgressViewer({
6767
const theme = useTheme();
6868

6969
let fillWidth =
70-
Math.round((parseFloat(String(value)) / parseFloat(String(capacity))) * 100) || 0;
70+
Math.floor((parseFloat(String(value)) / parseFloat(String(capacity))) * 100) || 0;
7171
fillWidth = fillWidth > 100 ? 100 : fillWidth;
7272
let valueText: number | string | undefined = value,
7373
capacityText: number | string | undefined = capacity,

src/containers/Cluster/ClusterInfo/components/DiskGroupsStatsBars/DiskGroupsStats.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function DiskGroupsStats({stats, storageType}: GroupsStatsPopupContentPro
3232
const convertedAllocatedSize = formatBytes({value: allocatedSize, size: sizeToConvert});
3333
const convertedAvailableSize = formatBytes({value: availableSize, size: sizeToConvert});
3434

35-
const usage = Math.round((allocatedSize / (allocatedSize + availableSize)) * 100);
35+
const usage = Math.floor((allocatedSize / (allocatedSize + availableSize)) * 100);
3636

3737
const info = [
3838
{

src/store/reducers/storage/__tests__/prepareGroupsDisks.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ describe('prepareGroupsVDisk', () => {
9292
AllocatedSize: 30943477760,
9393
AvailableSize: 234461593600,
9494
TotalSize: 265405071360,
95-
AllocatedPercent: 12,
95+
AllocatedPercent: 11,
9696

9797
Donors: undefined,
9898

@@ -135,7 +135,7 @@ describe('prepareGroupsVDisk', () => {
135135
AllocatedSize: 30943477760,
136136
AvailableSize: 234461593600,
137137
TotalSize: 265405071360,
138-
AllocatedPercent: 12,
138+
AllocatedPercent: 11,
139139

140140
PDisk: {
141141
AllocatedPercent: NaN,
@@ -237,7 +237,7 @@ describe('prepareGroupsVDisk', () => {
237237
AllocatedSize: 30943477760,
238238
AvailableSize: 234461593600,
239239
TotalSize: 265405071360,
240-
AllocatedPercent: 12,
240+
AllocatedPercent: 11,
241241

242242
Donors: undefined,
243243

src/utils/disks/__test__/prepareDisks.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ describe('prepareWhiteboardVDiskData', () => {
9191
AvailableSize: 188523479040,
9292
AllocatedSize: 8996782080,
9393
TotalSize: 197520261120,
94-
AllocatedPercent: 5,
94+
AllocatedPercent: 4,
9595
};
9696

9797
const preparedData = prepareWhiteboardVDiskData(data);
@@ -162,7 +162,7 @@ describe('prepareWhiteboardPDiskData', () => {
162162
AvailableSize: 3107979264000,
163163
TotalSize: 3199556648960,
164164
AllocatedSize: 91577384960,
165-
AllocatedPercent: 3,
165+
AllocatedPercent: 2,
166166

167167
ExpectedSlotCount: 16,
168168
NumActiveSlots: 10,

src/utils/disks/prepareDisks.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export function prepareVDiskSizeFields({
125125
const available = Number(AvailableSize);
126126
const allocated = Number(AllocatedSize);
127127
const total = allocated + available;
128-
const allocatedPercent = Math.round((allocated * 100) / total);
128+
const allocatedPercent = Math.floor((allocated * 100) / total);
129129

130130
return {
131131
AvailableSize: available,
@@ -145,7 +145,7 @@ export function preparePDiskSizeFields({
145145
const available = Number(AvailableSize);
146146
const total = Number(TotalSize);
147147
const allocated = total - available;
148-
const allocatedPercent = Math.round((allocated * 100) / total);
148+
const allocatedPercent = Math.floor((allocated * 100) / total);
149149

150150
return {
151151
AvailableSize: available,

0 commit comments

Comments
 (0)