Skip to content

Commit

Permalink
[ML] New Platform server shim: update data visualizer routes to use n…
Browse files Browse the repository at this point in the history
…ew platform router (#56739)

* [ML] data_visualizer TS refactor, NP router

* [ML] fix schema, add apiDoc

* [ML] update apiDoc order

* [ML] validate_cardinality with NP router

* [ML] use mlClient

* [ML] remove redundant code

* [ML] support legacy callWithRequest for job validation

* [ML] fix schema validation
  • Loading branch information
darnautov authored Feb 5, 2020
1 parent 367086b commit 625b93a
Show file tree
Hide file tree
Showing 8 changed files with 509 additions and 271 deletions.
2 changes: 2 additions & 0 deletions x-pack/legacy/plugins/ml/common/util/job_utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ export function processCreatedBy(customSettings: { created_by?: string }): void;
export function mlFunctionToESAggregation(functionName: string): string | null;

export function isModelPlotEnabled(job: Job, detectorIndex: number, entityFields: any[]): boolean;

export function getSafeAggregationName(fieldName: string, index: number): string;
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@

// Builds the base filter criteria used in queries,
// adding criteria for the time range and an optional query.
export function buildBaseFilterCriteria(timeFieldName, earliestMs, latestMs, query) {
export function buildBaseFilterCriteria(
timeFieldName?: string,
earliestMs?: number,
latestMs?: number,
query?: object
) {
const filterCriteria = [];
if (timeFieldName && earliestMs && latestMs) {
filterCriteria.push({
Expand All @@ -34,7 +39,7 @@ export function buildBaseFilterCriteria(timeFieldName, earliestMs, latestMs, que
// Wraps the supplied aggregations in a sampler aggregation.
// A supplied samplerShardSize (the shard_size parameter of the sampler aggregation)
// of less than 1 indicates no sampling, and the aggs are returned as-is.
export function buildSamplerAggregation(aggs, samplerShardSize) {
export function buildSamplerAggregation(aggs: object, samplerShardSize: number) {
if (samplerShardSize < 1) {
return aggs;
}
Expand All @@ -53,6 +58,6 @@ export function buildSamplerAggregation(aggs, samplerShardSize) {
// depending on whether sampling is being used.
// A supplied samplerShardSize (the shard_size parameter of the sampler aggregation)
// of less than 1 indicates no sampling, and an empty array is returned.
export function getSamplerAggregationsResponsePath(samplerShardSize) {
export function getSamplerAggregationsResponsePath(samplerShardSize: number): string[] {
return samplerShardSize > 0 ? ['sample'] : [];
}
Loading

0 comments on commit 625b93a

Please sign in to comment.