From 23d6f18b7b094e8be41d970a1e56b49226a77752 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Thu, 13 Jul 2023 12:06:08 -0700 Subject: [PATCH] [Vis Augmenter] Fix stats API visualization ID bug (#4565) (#4567) * Fix vis augmenter stats api vis ID map * Update changelog * Update tests * Remove changelog entry --------- (cherry picked from commit 72e7068a2e8b5f594eb2d7138cd9d46c0b1bd3ab) Signed-off-by: Tyler Ohlsen Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] --- .../server/routes/stats_helpers.test.ts | 41 ++++++++++++++++--- .../server/routes/stats_helpers.ts | 2 +- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/plugins/vis_augmenter/server/routes/stats_helpers.test.ts b/src/plugins/vis_augmenter/server/routes/stats_helpers.test.ts index 96f561c49e05..c0badd06e1ea 100644 --- a/src/plugins/vis_augmenter/server/routes/stats_helpers.test.ts +++ b/src/plugins/vis_augmenter/server/routes/stats_helpers.test.ts @@ -14,6 +14,7 @@ const PLUGIN_RESOURCE_TYPE_2 = 'plugin-resource-type-2'; const PLUGIN_RESOURCE_ID_1 = 'plugin-resource-id-1'; const PLUGIN_RESOURCE_ID_2 = 'plugin-resource-id-2'; const PLUGIN_RESOURCE_ID_3 = 'plugin-resource-id-3'; +const VIS_REF_NAME = 'visualization_0'; const VIS_ID_1 = 'vis-id-1'; const VIS_ID_2 = 'vis-id-2'; const PER_PAGE = 4; @@ -26,8 +27,14 @@ const SINGLE_SAVED_OBJ = [ type: PLUGIN_RESOURCE_TYPE_1, id: PLUGIN_RESOURCE_ID_1, }, - visId: VIS_ID_1, + visName: VIS_REF_NAME, }, + references: [ + { + name: VIS_REF_NAME, + id: VIS_ID_1, + }, + ], }, ] as Array>; @@ -39,8 +46,14 @@ const MULTIPLE_SAVED_OBJS = [ type: PLUGIN_RESOURCE_TYPE_1, id: PLUGIN_RESOURCE_ID_1, }, - visId: VIS_ID_1, + visName: VIS_REF_NAME, }, + references: [ + { + name: VIS_REF_NAME, + id: VIS_ID_1, + }, + ], }, { attributes: { @@ -49,8 +62,14 @@ const MULTIPLE_SAVED_OBJS = [ type: PLUGIN_RESOURCE_TYPE_2, id: PLUGIN_RESOURCE_ID_2, }, - visId: VIS_ID_1, + visName: VIS_REF_NAME, }, + references: [ + { + name: VIS_REF_NAME, + id: VIS_ID_1, + }, + ], }, { attributes: { @@ -59,8 +78,14 @@ const MULTIPLE_SAVED_OBJS = [ type: PLUGIN_RESOURCE_TYPE_2, id: PLUGIN_RESOURCE_ID_2, }, - visId: VIS_ID_2, + visName: VIS_REF_NAME, }, + references: [ + { + name: VIS_REF_NAME, + id: VIS_ID_2, + }, + ], }, { attributes: { @@ -69,8 +94,14 @@ const MULTIPLE_SAVED_OBJS = [ type: PLUGIN_RESOURCE_TYPE_2, id: PLUGIN_RESOURCE_ID_3, }, - visId: VIS_ID_1, + visName: VIS_REF_NAME, }, + references: [ + { + name: VIS_REF_NAME, + id: VIS_ID_1, + }, + ], }, ] as Array>; diff --git a/src/plugins/vis_augmenter/server/routes/stats_helpers.ts b/src/plugins/vis_augmenter/server/routes/stats_helpers.ts index 33e73ec47306..174e68e529c9 100644 --- a/src/plugins/vis_augmenter/server/routes/stats_helpers.ts +++ b/src/plugins/vis_augmenter/server/routes/stats_helpers.ts @@ -68,7 +68,7 @@ export const getStats = ( const originPlugin = augmentVisObj.attributes.originPlugin; const pluginResourceType = augmentVisObj.attributes.pluginResource.type; const pluginResourceId = augmentVisObj.attributes.pluginResource.id; - const visualizationId = augmentVisObj.attributes.visId as string; + const visualizationId = augmentVisObj.references[0].id as string; originPluginMap[originPlugin] = (get(originPluginMap, originPlugin, 0) as number) + 1; pluginResourceTypeMap[pluginResourceType] =