Skip to content

Commit

Permalink
fix(rhacs): sw-479 Core-hours to Cores metric (RedHatInsights#965)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcabrera committed Aug 29, 2022
1 parent f70224c commit 9df7b4e
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 49 deletions.
29 changes: 19 additions & 10 deletions public/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
"cardActionTotal": "{{total}} used",
"cardActionTotal_coreHours": "{{total}} core hours used",
"cardHeading": "CPU usage",
"cardHeading_Core-hours": "vCPU hours",
"cardHeading_cores": "CPU core usage",
"cardHeading_cores_OpenShift Container Platform": "CPU core usage",
"cardHeading_cores_OpenShift-metrics": "CPU core usage",
"cardHeading_cores_OpenShift-dedicated-metrics": "CPU core usage",
"cardHeading_Cores": "vCPU hours",
"cardHeading_sockets": "CPU socket usage",
"cardHeading_Instance-hours": "Instance hours",
"cardHeading_Storage-gibibytes": "Data storage",
Expand All @@ -31,7 +34,7 @@
"cardHeading_Satellite Capsule": "CPU socket usage",
"cardHeading_Satellite Server": "CPU socket usage",
"cardHeadingDescription": "...",
"cardHeadingDescription_Core-hours": "vCPU hours usage in hours",
"cardHeadingDescription_Cores": "vCPU hours usage in hours",
"cardHeadingDescription_Instance-hours": "Instance hours usage in hours",
"cardHeadingDescription_Storage-gibibytes": "Data storage usage in binary gigabyte hours",
"cardHeadingDescription_Storage-gibibyte-months": "Data storage usage in binary gigabyte months",
Expand All @@ -40,32 +43,35 @@
"cardHeadingDescription_OpenShift-metrics": "A subscription model that offers purchasing options to match your usage patterns.",
"cardHeadingDescription_OpenShift-dedicated-metrics": "A subscription model that offers purchasing options to match your usage patterns.",
"cardHeadingMetric_dailyTotal": "Daily total",
"cardHeadingMetric_dailyTotal_Core-hours": "Daily vCPU hours",
"cardHeadingMetric_dailyTotal_Cores": "Daily vCPU hours",
"cardHeadingMetric_dailyTotal_Instance-hours": "Daily instance hours",
"cardHeadingMetric_dailyTotal_Storage-gibibytes": "Daily data storage",
"cardHeadingMetric_dailyTotal_Storage-gibibyte-months": "Daily data storage",
"cardHeadingMetric_dailyTotal_Transfer-gibibytes": "Daily data transfer",
"cardHeadingMetric_monthlyTotal": "Monthly total",
"cardHeadingMetric_monthlyTotal_Core-hours": "Monthly vCPU hours",
"cardHeadingMetric_monthlyTotal_Cores": "Monthly vCPU hours",
"cardHeadingMetric_monthlyTotal_Instance-hours": "Monthly instance hours",
"cardHeadingMetric_monthlyTotal_Storage-gibibytes": "Monthly data storage",
"cardHeadingMetric_monthlyTotal_Storage-gibibyte-months": "Monthly data storage",
"cardHeadingMetric_monthlyTotal_Transfer-gibibytes": "Monthly data transfer",
"cardBodyMetric_total": "No data",
"cardBodyMetric_total_Core-hours": "<0>{{total}}</0> vCPU hours",
"cardBodyMetric_total_Cores": "<0>{{total}}</0> vCPU hours",
"cardBodyMetric_total_Instance-hours": "<0>{{total}}</0> Instance hours",
"cardBodyMetric_total_Storage-gibibytes": "<0>{{total}}</0> Binary gigabyte hours",
"cardBodyMetric_total_Storage-gibibyte-months": "<0>{{total}}</0> Binary gigabyte months",
"cardBodyMetric_total_Transfer-gibibytes": "<0>{{total}}</0> Binary gigabytes",
"cardFooterMetric": "Last update {{date}}",
"label_axisX_Daily": "Day of the month",
"label_axisY_Core-hours": "vCPU hours",
"label_axisY_Cores": "vCPU hours",
"label_axisY_Instance-hours": "Instance hours",
"label_axisY_Storage-gibibytes": "Binary gigabyte hours",
"label_axisY_Storage-gibibyte-months": "Binary gigabyte months",
"label_axisY_Transfer-gibibytes": "Binary gigabytes",
"label_Core-hours": "vCPU hours",
"label_cores": "Cores",
"label_cores_OpenShift Container Platform": "Cores",
"label_cores_OpenShift-metrics": "Cores",
"label_cores_OpenShift-dedicated-metrics": "Cores",
"label_Cores": "vCPU hours",
"label_coreHours": "Core hours",
"label_instanceHours": "Instance hours",
"label_Instance-hours": "Instance hours",
Expand All @@ -83,8 +89,11 @@
"label_threshold": "Subscription threshold",
"label_threshold_infinite": "unlimited",
"label_Transfer-gibibytes": "Data transfer",
"legendTooltip_Core-hours": "vCPU hours usage",
"legendTooltip_cores": "{{product}} CPU usage, per CPU core.",
"legendTooltip_cores_OpenShift Container Platform": "{{product}} CPU usage, per CPU core.",
"legendTooltip_cores_OpenShift-metrics": "{{product}} CPU usage, per CPU core.",
"legendTooltip_cores_OpenShift-dedicated-metrics": "{{product}} CPU usage, per CPU core.",
"legendTooltip_Cores": "vCPU hours usage",
"legendTooltip_coreHours": "{{product}} core hours usage.",
"legendTooltip_coreHours_OpenShift-dedicated-metrics": "OpenShift Dedicated <0>On-Demand</0> core hour usage.",
"legendTooltip_Instance-hours": "Instance hours usage",
Expand Down Expand Up @@ -146,7 +155,7 @@
"header_cores_OpenShift Container Platform": "Cores",
"header_cores_OpenShift-metrics": "Cores",
"header_cores_OpenShift-dedicated-metrics": "Cores",
"header_Core-hours": "vCPU hours",
"header_Cores": "vCPU hours",
"header_coreHours": "Core hours",
"header_displayName": "Name",
"header_display_name": "Name",
Expand Down Expand Up @@ -183,7 +192,7 @@
"measurement_billing_provider_none": "None",
"measurement_billing_provider_oracle": "Oracle",
"measurement_billing_provider_red hat": "Red Hat",
"measurement_Core-hours": "{{total}} hours",
"measurement_Cores": "{{total}} hours",
"measurement_Instance-hours": "{{total}} hours",
"measurement_Storage-gibibytes": "{{total}} GB hours",
"measurement_Storage-gibibyte-months": "{{total}} GB months",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ exports[`GraphCardChartTooltip Component should render basic data: data 1`] = `
</thead>
<tbody>
<tr
key="tooltip-t(curiosity-graph.label, {\\"context\\":\\"dolorSit\\"})"
key="tooltip-t(curiosity-graph.label_dolorSit, {})"
>
<th>
<ChartIcon
Expand All @@ -39,14 +39,14 @@ exports[`GraphCardChartTooltip Component should render basic data: data 1`] = `
title={null}
/>
t(curiosity-graph.label, {"context":"dolorSit"})
t(curiosity-graph.label_dolorSit, {})
</th>
<td>
1
</td>
</tr>
<tr
key="tooltip-t(curiosity-graph.label, {\\"context\\":\\"loremIpsum\\"})"
key="tooltip-t(curiosity-graph.label_loremIpsum, {})"
>
<th>
<ChartIcon
Expand All @@ -56,7 +56,7 @@ exports[`GraphCardChartTooltip Component should render basic data: data 1`] = `
title={null}
/>
t(curiosity-graph.label, {"context":"loremIpsum"})
t(curiosity-graph.label_loremIpsum, {})
</th>
<td>
0
Expand Down
4 changes: 2 additions & 2 deletions src/components/graphCard/graphCardChartTooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const GraphCardChartTooltip = ({
useProduct: useAliasProduct,
useProductGraphTallyQuery: useAliasProductGraphTallyQuery
}) => {
const { productLabel } = useAliasProduct();
const { productId, productLabel } = useAliasProduct();
const { [RHSM_API_QUERY_SET_TYPES.GRANULARITY]: granularity } = useAliasProductGraphTallyQuery();

let header = null;
Expand Down Expand Up @@ -68,7 +68,7 @@ const GraphCardChartTooltip = ({
itemsByKey[key]?.data.y ||
0;

tempDataFacet.label = t('curiosity-graph.label', { context: key, product: productLabel });
tempDataFacet.label = t(`curiosity-graph.label_${key}`, { context: productId, product: productLabel });
tempDataFacet.value = dataFactsValue;
}

Expand Down
10 changes: 3 additions & 7 deletions src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ Array [
"match": "t('curiosity-graph.label_noData')",
},
Object {
"key": "curiosity-graph.label",
"match": "t('curiosity-graph.label', { context: key, product: productLabel })",
"key": "",
"match": "t(\`curiosity-graph.label_\${key}\`, { context: productId, product: productLabel })",
},
Object {
"key": "curiosity-graph.tooltipSummary",
Expand Down Expand Up @@ -619,7 +619,7 @@ Array [
},
Object {
"key": "curiosity-inventory.measurement",
"match": "translate('curiosity-inventory.measurement', { context: RHSM_API_PATH_METRIC_TYPES.CORE_HOURS, total: helpers.numberDisplay(total?.value)",
"match": "translate('curiosity-inventory.measurement', { context: RHSM_API_PATH_METRIC_TYPES.CORES, total: helpers.numberDisplay(total?.value)",
},
Object {
"key": "",
Expand Down Expand Up @@ -752,10 +752,6 @@ Array [

exports[`I18n Component should have locale keys that exist in the default language JSON: missing locale keys 1`] = `
Array [
Object {
"file": "./src/components/graphCard/graphCardChartTooltip.js",
"key": "curiosity-graph.label",
},
Object {
"file": "./src/components/inventoryCard/inventoryCard.js",
"key": "curiosity-inventory.tab",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ exports[`InventoryCardContext should expect specific sort properties: sort prope
Object {
"BILLING_PROVIDER": "billing_provider",
"CORES": "Cores",
"CORE_HOURS": "Core-hours",
"CORE_SECONDS": "Core-seconds",
"INSTANCE_HOURS": "Instance-hours",
"LAST_SEEN": "last_seen",
Expand Down
18 changes: 9 additions & 9 deletions src/config/__tests__/__snapshots__/product.rhacs.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Object {
"title": "t(curiosity-inventory.measurement_billing_provider, {\\"context\\":\\"none\\"})",
},
Object {
"title": "t(curiosity-inventory.measurement, {\\"context\\":\\"Core-hours\\",\\"total\\":\\"200\\"})",
"title": "t(curiosity-inventory.measurement, {\\"context\\":\\"Cores\\",\\"total\\":\\"200\\"})",
},
Object {
"title": <DateFormat
Expand All @@ -30,7 +30,7 @@ Object {
],
},
Object {
"title": "t(curiosity-inventory.header, {\\"context\\":\\"Core-hours\\"})",
"title": "t(curiosity-inventory.header, {\\"context\\":\\"Cores\\"})",
"transforms": Array [
[Function],
],
Expand All @@ -43,8 +43,8 @@ Object {
},
],
"data": Object {
"Core-hours": Object {
"title": "t(curiosity-inventory.header, {\\"context\\":\\"Core-hours\\"})",
"Cores": Object {
"title": "t(curiosity-inventory.header, {\\"context\\":\\"Cores\\"})",
"value": 200,
},
"display_name": Object {
Expand Down Expand Up @@ -76,7 +76,7 @@ Object {
"title": "t(curiosity-inventory.measurement_billing_provider, {\\"context\\":\\"none\\"})",
},
Object {
"title": "t(curiosity-inventory.measurement, {\\"context\\":\\"Core-hours\\",\\"total\\":\\"200\\"})",
"title": "t(curiosity-inventory.measurement, {\\"context\\":\\"Cores\\",\\"total\\":\\"200\\"})",
},
Object {
"title": <DateFormat
Expand All @@ -96,7 +96,7 @@ Object {
],
},
Object {
"title": "t(curiosity-inventory.header, {\\"context\\":\\"Core-hours\\"})",
"title": "t(curiosity-inventory.header, {\\"context\\":\\"Cores\\"})",
"transforms": Array [
[Function],
],
Expand All @@ -109,8 +109,8 @@ Object {
},
],
"data": Object {
"Core-hours": Object {
"title": "t(curiosity-inventory.header, {\\"context\\":\\"Core-hours\\"})",
"Cores": Object {
"title": "t(curiosity-inventory.header, {\\"context\\":\\"Cores\\"})",
"value": 200,
},
"display_name": Object {
Expand All @@ -137,7 +137,7 @@ Object {
"chartType": "line",
"color": "#06c",
"fill": "#8bc1f7",
"id": "Core-hours",
"id": "Cores",
"isStacked": false,
"isStandalone": true,
"isThreshold": false,
Expand Down
2 changes: 1 addition & 1 deletion src/config/__tests__/product.rhacs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('Product RHACS config', () => {

const inventoryData = {
[INVENTORY_TYPES.DISPLAY_NAME]: 'lorem ipsum',
[RHSM_API_PATH_METRIC_TYPES.CORE_HOURS]: 200,
[RHSM_API_PATH_METRIC_TYPES.CORES]: 200,
[INVENTORY_TYPES.LAST_SEEN]: '2022-01-01T00:00:00.000Z'
};

Expand Down
8 changes: 4 additions & 4 deletions src/config/product.rhacs.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const config = {
},
initialGraphFilters: [
{
id: RHSM_API_PATH_METRIC_TYPES.CORE_HOURS,
id: RHSM_API_PATH_METRIC_TYPES.CORES,
fill: chartColorBlueLight.value,
stroke: chartColorBlueDark.value,
color: chartColorBlueDark.value,
Expand Down Expand Up @@ -129,10 +129,10 @@ const config = {
cellWidth: 15
},
{
id: RHSM_API_PATH_METRIC_TYPES.CORE_HOURS,
cell: ({ [RHSM_API_PATH_METRIC_TYPES.CORE_HOURS]: total }) =>
id: RHSM_API_PATH_METRIC_TYPES.CORES,
cell: ({ [RHSM_API_PATH_METRIC_TYPES.CORES]: total }) =>
translate('curiosity-inventory.measurement', {
context: RHSM_API_PATH_METRIC_TYPES.CORE_HOURS,
context: RHSM_API_PATH_METRIC_TYPES.CORES,
total: helpers.numberDisplay(total?.value)?.format({ mantissa: 5, trimMantissa: true }) || 0
}),
isSortable: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ exports[`RHSM Constants should have specific properties: all exported constants
Object {
"RHSM_API_PATH_METRIC_TYPES": Object {
"CORES": "Cores",
"CORE_HOURS": "Core-hours",
"CORE_SECONDS": "Core-seconds",
"INSTANCE_HOURS": "Instance-hours",
"SOCKETS": "Sockets",
Expand Down Expand Up @@ -48,7 +47,6 @@ Object {
"RHSM_API_QUERY_INVENTORY_SORT_TYPES": Object {
"BILLING_PROVIDER": "billing_provider",
"CORES": "Cores",
"CORE_HOURS": "Core-hours",
"CORE_SECONDS": "Core-seconds",
"INSTANCE_HOURS": "Instance-hours",
"LAST_SEEN": "last_seen",
Expand Down Expand Up @@ -226,7 +224,6 @@ Object {
"default": Object {
"RHSM_API_PATH_METRIC_TYPES": Object {
"CORES": "Cores",
"CORE_HOURS": "Core-hours",
"CORE_SECONDS": "Core-seconds",
"INSTANCE_HOURS": "Instance-hours",
"SOCKETS": "Sockets",
Expand Down Expand Up @@ -270,7 +267,6 @@ Object {
"RHSM_API_QUERY_INVENTORY_SORT_TYPES": Object {
"BILLING_PROVIDER": "billing_provider",
"CORES": "Cores",
"CORE_HOURS": "Core-hours",
"CORE_SECONDS": "Core-seconds",
"INSTANCE_HOURS": "Instance-hours",
"LAST_SEEN": "last_seen",
Expand Down Expand Up @@ -449,7 +445,6 @@ Object {
"rhsmConstants": Object {
"RHSM_API_PATH_METRIC_TYPES": Object {
"CORES": "Cores",
"CORE_HOURS": "Core-hours",
"CORE_SECONDS": "Core-seconds",
"INSTANCE_HOURS": "Instance-hours",
"SOCKETS": "Sockets",
Expand Down Expand Up @@ -493,7 +488,6 @@ Object {
"RHSM_API_QUERY_INVENTORY_SORT_TYPES": Object {
"BILLING_PROVIDER": "billing_provider",
"CORES": "Cores",
"CORE_HOURS": "Core-hours",
"CORE_SECONDS": "Core-seconds",
"INSTANCE_HOURS": "Instance-hours",
"LAST_SEEN": "last_seen",
Expand Down Expand Up @@ -676,7 +670,6 @@ exports[`RHSM Constants should have specific properties: specific constants 1`]
Object {
"RHSM_API_PATH_METRIC_TYPES": Object {
"CORES": "Cores",
"CORE_HOURS": "Core-hours",
"CORE_SECONDS": "Core-seconds",
"INSTANCE_HOURS": "Instance-hours",
"SOCKETS": "Sockets",
Expand Down Expand Up @@ -720,7 +713,6 @@ Object {
"RHSM_API_QUERY_INVENTORY_SORT_TYPES": Object {
"BILLING_PROVIDER": "billing_provider",
"CORES": "Cores",
"CORE_HOURS": "Core-hours",
"CORE_SECONDS": "Core-seconds",
"INSTANCE_HOURS": "Instance-hours",
"LAST_SEEN": "last_seen",
Expand Down
5 changes: 2 additions & 3 deletions src/services/rhsm/rhsmConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ const RHSM_API_PATH_PRODUCT_TYPES = {
/**
* RHSM path IDs for metrics.
*
* @type {{CORES: string, CORE_HOURS: string, STORAGE_GIBIBYTES: string, SOCKETS: string, INSTANCE_HOURS: string,
* @type {{CORES: string, STORAGE_GIBIBYTES: string, SOCKETS: string, INSTANCE_HOURS: string,
* TRANSFER_GIBIBYTES: string, CORE_SECONDS: string, STORAGE_GIBIBYTE_MONTHS: string}}
*/
const RHSM_API_PATH_METRIC_TYPES = {
CORES: 'Cores',
SOCKETS: 'Sockets',
CORE_HOURS: 'Core-hours',
CORE_SECONDS: 'Core-seconds',
INSTANCE_HOURS: 'Instance-hours',
STORAGE_GIBIBYTES: 'Storage-gibibytes',
Expand Down Expand Up @@ -380,7 +379,7 @@ const RHSM_INTERNAL_PRODUCT_DISPLAY_TYPES = {
*
* @type {{RHSM_API_QUERY_SET_TALLY_CAPACITY_TYPES: {GRANULARITY: string, USAGE: string, END_DATE: string, SLA: string, START_DATE: string,
* BILLING_PROVIDER: string}, RHSM_API_RESPONSE_DATA: string, RHSM_API_RESPONSE_SUBSCRIPTIONS_META_TYPES: {PRODUCT: string,
* SUBSCRIPTION_TYPE: string, COUNT: string}, RHSM_API_PATH_METRIC_TYPES: {CORES: string, CORE_HOURS: string, STORAGE_GIBIBYTES: string,
* SUBSCRIPTION_TYPE: string, COUNT: string}, RHSM_API_PATH_METRIC_TYPES: {CORES: string, STORAGE_GIBIBYTES: string,
* SOCKETS: string, INSTANCE_HOURS: string, TRANSFER_GIBIBYTES: string, CORE_SECONDS: string, STORAGE_GIBIBYTE_MONTHS: string},
* RHSM_API_RESPONSE_TALLY_DATA_TYPES: {DATE: string, HAS_DATA: string, VALUE: string},
* RHSM_API_RESPONSE_INSTANCES_META_TYPES: {MEASUREMENTS: string, PRODUCT: string, COUNT: string},
Expand Down

0 comments on commit 9df7b4e

Please sign in to comment.