Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
VladLasitsa committed May 5, 2020
1 parent 61b7d06 commit c9ce18d
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 48 deletions.
9 changes: 2 additions & 7 deletions src/plugins/data/public/search/aggs/metrics/bucket_avg_fn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ export const aggBucketAvg = (): FunctionDefinition => ({
fn: (input, args) => {
const { id, enabled, schema, ...rest } = args;

// Need to spread this object to work around TS bug:
// https://github.com/microsoft/TypeScript/issues/15300#issuecomment-436793742
const customBucket = args.customBucket?.value ? { ...args.customBucket.value } : undefined;
const customMetric = args.customMetric?.value ? { ...args.customMetric.value } : undefined;

return {
type: 'agg_type',
value: {
Expand All @@ -102,8 +97,8 @@ export const aggBucketAvg = (): FunctionDefinition => ({
type: METRIC_TYPES.AVG_BUCKET,
params: {
...rest,
customBucket,
customMetric,
customBucket: args.customBucket?.value,
customMetric: args.customMetric?.value,
json: getParsedValue(args, 'json'),
},
},
Expand Down
9 changes: 2 additions & 7 deletions src/plugins/data/public/search/aggs/metrics/bucket_max_fn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ export const aggBucketMax = (): FunctionDefinition => ({
fn: (input, args) => {
const { id, enabled, schema, ...rest } = args;

// Need to spread this object to work around TS bug:
// https://github.com/microsoft/TypeScript/issues/15300#issuecomment-436793742
const customBucket = args.customBucket?.value ? { ...args.customBucket.value } : undefined;
const customMetric = args.customMetric?.value ? { ...args.customMetric.value } : undefined;

return {
type: 'agg_type',
value: {
Expand All @@ -102,8 +97,8 @@ export const aggBucketMax = (): FunctionDefinition => ({
type: METRIC_TYPES.MAX_BUCKET,
params: {
...rest,
customBucket,
customMetric,
customBucket: args.customBucket?.value,
customMetric: args.customMetric?.value,
json: getParsedValue(args, 'json'),
},
},
Expand Down
9 changes: 2 additions & 7 deletions src/plugins/data/public/search/aggs/metrics/bucket_min_fn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ export const aggBucketMin = (): FunctionDefinition => ({
fn: (input, args) => {
const { id, enabled, schema, ...rest } = args;

// Need to spread this object to work around TS bug:
// https://github.com/microsoft/TypeScript/issues/15300#issuecomment-436793742
const customBucket = args.customBucket?.value ? { ...args.customBucket.value } : undefined;
const customMetric = args.customMetric?.value ? { ...args.customMetric.value } : undefined;

return {
type: 'agg_type',
value: {
Expand All @@ -102,8 +97,8 @@ export const aggBucketMin = (): FunctionDefinition => ({
type: METRIC_TYPES.MIN_BUCKET,
params: {
...rest,
customBucket,
customMetric,
customBucket: args.customBucket?.value,
customMetric: args.customMetric?.value,
json: getParsedValue(args, 'json'),
},
},
Expand Down
9 changes: 2 additions & 7 deletions src/plugins/data/public/search/aggs/metrics/bucket_sum_fn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ export const aggBucketSum = (): FunctionDefinition => ({
fn: (input, args) => {
const { id, enabled, schema, ...rest } = args;

// Need to spread this object to work around TS bug:
// https://github.com/microsoft/TypeScript/issues/15300#issuecomment-436793742
const customBucket = args.customBucket?.value ? { ...args.customBucket.value } : undefined;
const customMetric = args.customMetric?.value ? { ...args.customMetric.value } : undefined;

return {
type: 'agg_type',
value: {
Expand All @@ -102,8 +97,8 @@ export const aggBucketSum = (): FunctionDefinition => ({
type: METRIC_TYPES.SUM_BUCKET,
params: {
...rest,
customBucket,
customMetric,
customBucket: args.customBucket?.value,
customMetric: args.customMetric?.value,
json: getParsedValue(args, 'json'),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ export const aggCumulativeSum = (): FunctionDefinition => ({
fn: (input, args) => {
const { id, enabled, schema, ...rest } = args;

// Need to spread this object to work around TS bug:
// https://github.com/microsoft/TypeScript/issues/15300#issuecomment-436793742
const customMetric = args.customMetric?.value ? { ...args.customMetric.value } : undefined;

return {
type: 'agg_type',
value: {
Expand All @@ -106,7 +102,7 @@ export const aggCumulativeSum = (): FunctionDefinition => ({
type: METRIC_TYPES.CUMULATIVE_SUM,
params: {
...rest,
customMetric,
customMetric: args.customMetric?.value,
json: getParsedValue(args, 'json'),
},
},
Expand Down
6 changes: 1 addition & 5 deletions src/plugins/data/public/search/aggs/metrics/derivative_fn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ export const aggDerivative = (): FunctionDefinition => ({
fn: (input, args) => {
const { id, enabled, schema, ...rest } = args;

// Need to spread this object to work around TS bug:
// https://github.com/microsoft/TypeScript/issues/15300#issuecomment-436793742
const customMetric = args.customMetric?.value ? { ...args.customMetric.value } : undefined;

return {
type: 'agg_type',
value: {
Expand All @@ -106,7 +102,7 @@ export const aggDerivative = (): FunctionDefinition => ({
type: METRIC_TYPES.DERIVATIVE,
params: {
...rest,
customMetric,
customMetric: args.customMetric?.value,
json: getParsedValue(args, 'json'),
},
},
Expand Down
6 changes: 1 addition & 5 deletions src/plugins/data/public/search/aggs/metrics/moving_avg_fn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ export const aggMovingAvg = (): FunctionDefinition => ({
fn: (input, args) => {
const { id, enabled, schema, ...rest } = args;

// Need to spread this object to work around TS bug:
// https://github.com/microsoft/TypeScript/issues/15300#issuecomment-436793742
const customMetric = args.customMetric?.value ? { ...args.customMetric.value } : undefined;

return {
type: 'agg_type',
value: {
Expand All @@ -119,7 +115,7 @@ export const aggMovingAvg = (): FunctionDefinition => ({
type: METRIC_TYPES.MOVING_FN,
params: {
...rest,
customMetric,
customMetric: args.customMetric?.value,
json: getParsedValue(args, 'json'),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ export const aggSerialDiff = (): FunctionDefinition => ({
fn: (input, args) => {
const { id, enabled, schema, ...rest } = args;

// Need to spread this object to work around TS bug:
// https://github.com/microsoft/TypeScript/issues/15300#issuecomment-436793742
const customMetric = args.customMetric?.value ? { ...args.customMetric.value } : undefined;

return {
type: 'agg_type',
value: {
Expand All @@ -106,7 +102,7 @@ export const aggSerialDiff = (): FunctionDefinition => ({
type: METRIC_TYPES.SERIAL_DIFF,
params: {
...rest,
customMetric,
customMetric: args.customMetric?.value,
json: getParsedValue(args, 'json'),
},
},
Expand Down

0 comments on commit c9ce18d

Please sign in to comment.