[ML] Fix annotation detector linking & delayed_data(0) (#72468)

This commit is contained in:
Quynh Nguyen 2020-07-20 19:34:53 -05:00 committed by GitHub
parent 21977a7e6a
commit 3760dc4f45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -256,7 +256,7 @@ export class AnnotationsTable extends Component {
// if the annotation is at the series level
// then pass the partitioning field(s) and detector index to the Single Metric Viewer
if (_.has(annotation, 'detector_index')) {
mlTimeSeriesExplorer.detector_index = annotation.detector_index;
mlTimeSeriesExplorer.detectorIndex = annotation.detector_index;
}
if (_.has(annotation, 'partition_field_value')) {
entityCondition[annotation.partition_field_name] = annotation.partition_field_value;
@ -523,10 +523,26 @@ export class AnnotationsTable extends Component {
const aggregations = this.props.aggregations ?? this.state.aggregations;
if (aggregations) {
const buckets = aggregations.event.buckets;
const foundUser = buckets.findIndex((d) => d.key === ANNOTATION_EVENT_USER) > -1;
filterOptions = foundUser
? buckets
: [{ key: ANNOTATION_EVENT_USER, doc_count: 0 }, ...buckets];
let foundUser = false;
let foundDelayedData = false;
buckets.forEach((bucket) => {
if (bucket.key === ANNOTATION_EVENT_USER) {
foundUser = true;
}
if (bucket.key === ANNOTATION_EVENT_DELAYED_DATA) {
foundDelayedData = true;
}
});
const adjustedBuckets = [];
if (!foundUser) {
adjustedBuckets.push({ key: ANNOTATION_EVENT_USER, doc_count: 0 });
}
if (!foundDelayedData) {
adjustedBuckets.push({ key: ANNOTATION_EVENT_DELAYED_DATA, doc_count: 0 });
}
filterOptions = [...adjustedBuckets, ...buckets];
}
const filters = [
{