Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Vis Augmenter] Fix stats API visualization ID bug #4565

Merged
merged 4 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Update main menu to display 'Dashboards' for consistency ([#4453](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4453))
- [Multiple DataSource] Retain the original sample data API ([#4526](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4526))
- Fix Node.js download link ([#4556](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4556))
- Fix stats API visualization ID bug ([#4565](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4565))

### 🚞 Infrastructure

Expand Down
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
Loading