File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -434,16 +434,22 @@ export function defineRoutes(router: IRouter, dataSourceEnabled: boolean) {
434434 wlmGroupId ?: string ;
435435 } ;
436436
437- const client =
438- ! dataSourceEnabled || ! dataSourceId
439- ? context . queryInsights_plugin . queryInsightsClient . asScoped ( request ) . callAsCurrentUser
440- : context . dataSource . opensearch . legacy . getClient ( dataSourceId ) ;
441-
442437 // Call the appropriate API based on whether wlm_group is provided
443438 const hasGroup = typeof wlmGroup === 'string' && wlmGroup . trim ( ) . length > 0 ;
444- const res = hasGroup
445- ? await client ( 'queryInsights.getLiveQueriesWLMGroup' , { wlmGroupId : wlmGroup } )
446- : await client ( 'queryInsights.getLiveQueries' ) ;
439+ let res ;
440+
441+ if ( ! dataSourceEnabled || ! dataSourceId ) {
442+ const client = context . queryInsights_plugin . queryInsightsClient . asScoped ( request )
443+ . callAsCurrentUser ;
444+ res = hasGroup
445+ ? await client ( 'queryInsights.getLiveQueriesWLMGroup' , { wlmGroupId : wlmGroup } )
446+ : await client ( 'queryInsights.getLiveQueries' ) ;
447+ } else {
448+ const client = context . dataSource . opensearch . legacy . getClient ( dataSourceId ) ;
449+ res = hasGroup
450+ ? await client . callAPI ( 'queryInsights.getLiveQueriesWLMGroup' , { wlmGroupId : wlmGroup } )
451+ : await client . callAPI ( 'queryInsights.getLiveQueries' , { } ) ;
452+ }
447453
448454 if ( ! res || res . ok === false ) {
449455 throw new Error ( res ?. error || 'Query Insights service returned an error' ) ;
You can’t perform that action at this time.
0 commit comments