Skip to content

Commit

Permalink
[Vis Augmenter] Fix stats API visualization ID bug (#4565)
Browse files Browse the repository at this point in the history
* Fix vis augmenter stats api vis ID map

Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>

* Update changelog

Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>

* Update tests

Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>

* Remove changelog entry

Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>

---------

Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>
(cherry picked from commit 72e7068)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Jul 13, 2023
1 parent ab5017a commit ff414b5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
41 changes: 36 additions & 5 deletions src/plugins/vis_augmenter/server/routes/stats_helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<SavedObjectsFindResult<AugmentVisSavedObjectAttributes>>;

Expand All @@ -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: {
Expand All @@ -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: {
Expand All @@ -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: {
Expand All @@ -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<SavedObjectsFindResult<AugmentVisSavedObjectAttributes>>;

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/vis_augmenter/server/routes/stats_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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] =
Expand Down

0 comments on commit ff414b5

Please sign in to comment.