Skip to content

Commit

Permalink
Removing the setTimeout code to simplify to a for/of
Browse files Browse the repository at this point in the history
  • Loading branch information
simianhacker committed Dec 23, 2021
1 parent 30cffea commit a691f9c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 32 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { UNGROUPED_FACTORY_KEY } from '../../common/utils';
import { MetricExpressionParams, Comparator, Aggregators } from '../types';
import { getElasticsearchMetricQuery } from './metric_query';
import { createTimerange } from './create_timerange';
import { doWork } from './do_work';

interface AggregationWithoutIntervals {
aggregatedValue: { value: number; values?: Array<{ key: number; value: number }> };
Expand Down Expand Up @@ -204,23 +203,17 @@ const getMetric: (
afterKeyHandler
)) as Array<Aggregation & { key: Record<string, string>; doc_count: number }>;
const groupedResults: Record<string, any> = {};
await Promise.all(
compositeBuckets.map((bucket) => {
return doWork(() => {
const key = Object.values(bucket.key)
.map((value) => value)
.join(', ');
const value = getValuesFromAggregations(
bucket,
aggType,
dropPartialBucketsOptions,
calculatedTimerange,
bucket.doc_count
);
groupedResults[key] = value;
});
})
);
for (const bucket of compositeBuckets) {
const key = Object.values(bucket.key).join(', ');
const value = getValuesFromAggregations(
bucket,
aggType,
dropPartialBucketsOptions,
calculatedTimerange,
bucket.doc_count
);
groupedResults[key] = value;
}
return groupedResults;
}
const { body: result } = await esClient.search({
Expand Down

0 comments on commit a691f9c

Please sign in to comment.