Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit precision of CPU/Memory/Volume maximums #3371

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions locales/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -12186,15 +12186,15 @@
"usageSubtitle": [
{
"type": 1,
"value": "count"
"value": "value"
},
{
"type": 0,
"value": " "
},
{
"type": 1,
"value": "countUnits"
"value": "units"
},
{
"type": 0,
Expand Down
2 changes: 1 addition & 1 deletion locales/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@
"usage": "Usage",
"usageCostDesc": "The portion of cost calculated by applying hourly and/or monthly price list rates to metrics.",
"usageCostTitle": "Usage cost",
"usageSubtitle": "{count} {countUnits} maximum",
"usageSubtitle": "{value} {units} maximum",
"various": "Various",
"volumeTitle": "Volume",
"workerUnallocated": "Worker unallocated",
Expand Down
4 changes: 2 additions & 2 deletions src/locales/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3407,8 +3407,8 @@ export default defineMessages({
id: 'usageCostTitle',
},
usageSubtitle: {
defaultMessage: '{count} {countUnits} maximum',
description: '{count} {countUnits} maximum',
defaultMessage: '{value} {units} maximum',
description: '{value} {units} maximum',
id: 'usageSubtitle',
},
various: {
Expand Down
7 changes: 3 additions & 4 deletions src/routes/details/components/usageChart/usageChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -415,14 +415,13 @@ class UsageChartBase extends React.Component<UsageChartProps, UsageChartState> {
}

const { hasCapacityCount, hasCapacityCountUnits } = this.getHasData();

const count = hasCapacityCount ? report.meta.total.capacity.count : 0;
const countUnits = intl.formatMessage(messages.units, {
const units = intl.formatMessage(messages.units, {
units: unitsLookupKey(hasCapacityCountUnits ? report.meta.total.capacity.count_units : undefined),
});
const value = formatUnits(hasCapacityCount ? report.meta.total.capacity.count : 0, units);

if (hasCapacityCount && hasCapacityCountUnits) {
return <div style={styles.subtitle}>{intl.formatMessage(messages.usageSubtitle, { count, countUnits })}</div>;
return <div style={styles.subtitle}>{intl.formatMessage(messages.usageSubtitle, { value, units })}</div>;
}
return null;
}
Expand Down
3 changes: 2 additions & 1 deletion src/utils/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export const formatUnits: Formatter = (value, units, options) => {

switch (lookup) {
case 'byte_ms':
case 'core':
case 'core_hours':
case 'hour':
case 'hrs':
Expand Down Expand Up @@ -181,7 +182,7 @@ const formatUsage: UnitsFormatter = (
value,
options: FormatOptions = {
minimumFractionDigits: 0,
maximumFractionDigits: 0,
maximumFractionDigits: 2,
}
) => {
return value.toLocaleString(getLocale(), options);
Expand Down
Loading