From 04963bee99a68e1d6fc65446d0f680f5265fd606 Mon Sep 17 00:00:00 2001 From: Patricio Albizu <79482271+palbizu@users.noreply.github.com> Date: Thu, 7 Sep 2023 12:24:38 -0300 Subject: [PATCH] feat: Removing rate sec/min from aggregations (#2385) * feat: Removing rate sec/min from aggregations * feat: renaming --------- Co-authored-by: Patricio Albizu --- .../explore-query-order-by-editor.component.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/projects/observability/src/shared/components/explore-query-editor/order-by/explore-query-order-by-editor.component.ts b/projects/observability/src/shared/components/explore-query-editor/order-by/explore-query-order-by-editor.component.ts index d52c23351..4ae2c05a0 100644 --- a/projects/observability/src/shared/components/explore-query-editor/order-by/explore-query-order-by-editor.component.ts +++ b/projects/observability/src/shared/components/explore-query-editor/order-by/explore-query-order-by-editor.component.ts @@ -1,6 +1,7 @@ import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, Output } from '@angular/core'; import { TypedSimpleChanges } from '@hypertrace/common'; import { SelectOption, SelectSearchMode } from '@hypertrace/components'; +import { difference } from 'lodash-es'; import { combineLatest, Observable, of, ReplaySubject, Subject } from 'rxjs'; import { map, switchMap, take } from 'rxjs/operators'; import { AttributeMetadata } from '../../../graphql/model/metadata/attribute-metadata'; @@ -9,6 +10,7 @@ import { GraphQlSortDirection } from '../../../graphql/model/schema/sort/graphql import { TraceType } from '../../../graphql/model/schema/trace'; import { MetadataService } from '../../../services/metadata/metadata.service'; import { ExploreOrderBy } from '../explore-visualization-builder'; + @Component({ selector: 'ht-explore-query-order-by-editor', styleUrls: ['./explore-query-order-by-editor.component.scss'], @@ -98,6 +100,10 @@ export class ExploreQueryOrderByEditorComponent implements OnChanges { private readonly defaultDirection: GraphQlSortDirection = SortDirection.Asc; private readonly incomingOrderByExpressionSubject: Subject = new ReplaySubject(1); private readonly contextSubject: Subject = new ReplaySubject(1); + private readonly redundantOrderingAggregations: MetricAggregationType[] = [ + MetricAggregationType.AvgrateSecond, + MetricAggregationType.AvgrateMinute + ]; public constructor(private readonly metadataService: MetadataService) { this.selectedAggregation$ = combineLatest([this.contextSubject, this.incomingOrderByExpressionSubject]).pipe( @@ -206,6 +212,8 @@ export class ExploreQueryOrderByEditorComponent implements OnChanges { } return this.metadataService.getSelectionAttributes(context).pipe( + map(attributes => this.removeRedundantOrderingAggregations(attributes, this.redundantOrderingAggregations)), + map(attributes => attributes.filter(attribute => attribute.allowedAggregations.length > 0)), // Removes attributes without aggregations map(attributes => attributes.map(attribute => ({ value: attribute, @@ -215,6 +223,16 @@ export class ExploreQueryOrderByEditorComponent implements OnChanges { ); } + private removeRedundantOrderingAggregations( + attributes: AttributeMetadata[], + redundantOrderingAggregations: MetricAggregationType[] + ): AttributeMetadata[] { + return attributes.map(attribute => ({ + ...attribute, + allowedAggregations: difference(attribute.allowedAggregations, redundantOrderingAggregations) + })); + } + private buildOrderExpression( attribute: AttributeMetadata, aggregation: MetricAggregationType,