Skip to content

Commit

Permalink
fix: apply decimal place rounding to session usage (#2662)
Browse files Browse the repository at this point in the history
follows #2518
resolves [Teams threads](https://teams.microsoft.com/l/message/19:[email protected]/1724737890117?tenantId=13c6a44d-9b52-4b9e-aa34-0513ee7131f2&groupId=b1f3bcf4-facf-40d3-94ab-169abb4f0f52&parentMessageId=1724640841809&teamName=customers%20%26%20clients&channelName=SEC%20GTR&createdTime=1724737890117)

### TL;DR

Improved formatting of RAM and GPU memory usage display in session list.

### What changed?

- Added a new static method `_prefixFormatWithTrailingZeros` to format numbers with a fixed number of decimal places.
- Updated the RAM and GPU memory usage display to use the new formatting method, ensuring consistent decimal places.

### How to test?

1. Open the session list view.
2. Create or connect to a session with active resource usage.
3. Verify that the RAM and GPU memory usage values are displayed with two decimal places consistently.
4. Check different sessions with varying resource usage to ensure the formatting is applied correctly in all cases.

### Why make this change?

This change improves the readability and consistency of resource usage information in the session list. By formatting the RAM and GPU memory usage values with a fixed number of decimal places, it becomes easier for users to compare resource utilization across different sessions at a glance.

---

<!--
Please precisely, concisely, and concretely describe what this PR changes, the rationale behind codes,
and how it affects the users and other developers.
-->

**Checklist:** (if applicable)

- [x] Mention to the original issue
- [ ] Documentation
- [x] Minium required manager version: 23.09
- [x] Specific setting for review (eg., KB link, endpoint or how to setup)
- [x] Minimum requirements to check during review
- [ ] Test case(s) to demonstrate the difference of before/after
  • Loading branch information
agatha197 committed Aug 30, 2024
1 parent 6a32e76 commit b37471a
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 141 deletions.
5 changes: 2 additions & 3 deletions react/src/helper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,8 @@ export function toFixedFloorWithoutTrailingZeros(
num: number | string,
fixed: number,
) {
return typeof num === 'number'
? parseFloat(num.toFixed(fixed)).toString()
: parseFloat(parseFloat(num).toFixed(fixed)).toString();
const number = typeof num === 'string' ? parseFloat(num) : num;
return parseFloat(number.toFixed(fixed)).toString();
}

export function toFixedWithTypeValidation(num: number | string, fixed: number) {
Expand Down
Loading

0 comments on commit b37471a

Please sign in to comment.