Skip to content

Commit

Permalink
ensure job id string is corrrect
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarezmelissa87 committed Nov 16, 2023
1 parent 3bc2c8d commit 73216d0
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions x-pack/plugins/ml/server/routes/trained_models.ts
Expand Up @@ -193,17 +193,18 @@ export function trainedModelsRoutes(
const filteredModels = filterForEnabledFeatureModels(result, getEnabledFeatures());

try {
const jobIdsString = filteredModels.reduce((jobIdsStr, currentModel, idx) => {
let id = currentModel.metadata?.analytics_config?.id ?? '';
if (id !== '') {
id = `${idx > 0 ? ',' : ''}${id}*`;
}
return `${jobIdsStr}${id}`;
}, '');
const jobIds = filteredModels
.map((model) => {
const id = model.metadata?.analytics_config?.id;
if (id) {
return `${id}*`;
}
})
.filter((id) => id !== undefined);

if (jobIdsString !== '') {
if (jobIds.length) {
const { data_frame_analytics: jobs } = await mlClient.getDataFrameAnalytics({
id: jobIdsString,
id: jobIds.join(','),
allow_no_match: true,
});

Expand Down

0 comments on commit 73216d0

Please sign in to comment.