Skip to content

Commit

Permalink
Merge pull request #3371 from dlabrecq/format
Browse files Browse the repository at this point in the history
Limit precision of CPU/Memory/Volume maximums
  • Loading branch information
dlabrecq authored Aug 31, 2023
2 parents 95d7df6 + 3fc856a commit a6fc8c5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
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

0 comments on commit a6fc8c5

Please sign in to comment.