From 01fa620b3befdea3d24431d080eff78692efd4c7 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Fri, 29 Jul 2022 16:00:19 +0200 Subject: [PATCH 1/2] [ML] Explain log rates spikes: Fix API messages translations. --- .../server/routes/explain_log_rate_spikes.ts | 60 ++++++++++++++----- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/x-pack/plugins/aiops/server/routes/explain_log_rate_spikes.ts b/x-pack/plugins/aiops/server/routes/explain_log_rate_spikes.ts index 65ed2065d7ade..cb0911e1c53be 100644 --- a/x-pack/plugins/aiops/server/routes/explain_log_rate_spikes.ts +++ b/x-pack/plugins/aiops/server/routes/explain_log_rate_spikes.ts @@ -7,6 +7,7 @@ import { chunk } from 'lodash'; +import { i18n } from '@kbn/i18n'; import { asyncForEach } from '@kbn/std'; import type { IRouter } from '@kbn/core/server'; import { KBN_FIELD_TYPES } from '@kbn/field-types'; @@ -81,7 +82,12 @@ export const defineExplainLogRateSpikesRoute = ( updateLoadingStateAction({ ccsWarning: false, loaded, - loadingState: 'Loading field candidates.', + loadingState: i18n.translate( + 'xpack.aiops.explainLogRateSpikes.loadingState.loadingFieldCandidates', + { + defaultMessage: 'Loading field candidates.', + } + ), }) ); @@ -104,7 +110,16 @@ export const defineExplainLogRateSpikesRoute = ( updateLoadingStateAction({ ccsWarning: false, loaded, - loadingState: `Identified ${fieldCandidates.length} field candidates.`, + loadingState: i18n.translate( + 'xpack.aiops.explainLogRateSpikes.loadingState.identifiedFieldCandidates', + { + defaultMessage: + 'Identified {fieldCandidatesCount, plural, one {# field candidate} other {# field candidates}}.', + values: { + fieldCandidatesCount: fieldCandidates.length, + }, + } + ), }) ); @@ -144,9 +159,16 @@ export const defineExplainLogRateSpikesRoute = ( updateLoadingStateAction({ ccsWarning: false, loaded, - loadingState: `Identified ${ - changePoints?.length ?? 0 - } significant field/value pairs.`, + loadingState: i18n.translate( + 'xpack.aiops.explainLogRateSpikes.loadingState.identifiedFieldValuePairs', + { + defaultMessage: + 'Identified {fieldValuePairsCount, plural, one {# significant field/value pair} other {# significant field/value pairs}}.', + values: { + fieldValuePairsCount: changePoints?.length ?? 0, + }, + } + ), }) ); @@ -157,14 +179,6 @@ export const defineExplainLogRateSpikesRoute = ( } if (changePoints?.length === 0) { - push( - updateLoadingStateAction({ - ccsWarning: false, - loaded: 1, - loadingState: `Done.`, - }) - ); - end(); return; } @@ -239,7 +253,12 @@ export const defineExplainLogRateSpikesRoute = ( updateLoadingStateAction({ ccsWarning: false, loaded, - loadingState: `Loading histogram data.`, + loadingState: i18n.translate( + 'xpack.aiops.explainLogRateSpikes.loadingState.loadingHistogramData', + { + defaultMessage: 'Loading histogram data.', + } + ), }) ); push( @@ -255,6 +274,19 @@ export const defineExplainLogRateSpikesRoute = ( }); } + push( + updateLoadingStateAction({ + ccsWarning: false, + loaded: 1, + loadingState: i18n.translate( + 'xpack.aiops.explainLogRateSpikes.loadingState.doneMessage', + { + defaultMessage: 'Done.', + } + ), + }) + ); + end(); })(); From bb99a53a7061d42bfa50fad2877ec8bb7e1b9092 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Fri, 29 Jul 2022 17:25:20 +0200 Subject: [PATCH 2/2] [ML] Fix API integration tests. --- .../api_integration/apis/aiops/explain_log_rate_spikes.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/test/api_integration/apis/aiops/explain_log_rate_spikes.ts b/x-pack/test/api_integration/apis/aiops/explain_log_rate_spikes.ts index f2b606ff183cd..5bf3ae04a2743 100644 --- a/x-pack/test/api_integration/apis/aiops/explain_log_rate_spikes.ts +++ b/x-pack/test/api_integration/apis/aiops/explain_log_rate_spikes.ts @@ -34,8 +34,8 @@ export default ({ getService }: FtrProviderContext) => { }; const expected = { - chunksLength: 12, - actionsLength: 11, + chunksLength: 13, + actionsLength: 12, noIndexChunksLength: 4, noIndexActionsLength: 3, changePointFilter: 'add_change_points',