Skip to content

Commit

Permalink
refactor: change param name
Browse files Browse the repository at this point in the history
calculationOptions -> calculateOptions
  • Loading branch information
ZuperZee committed Mar 4, 2021
1 parent 0398763 commit c0ac318
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/utils/metricData/getMetricData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function getMetricData(
showcaseCalcs,
timeRange,
decimals,
calculateOptions,
calculationOptions,
}: MetricDataOptions = {}
): MetricData {
if (showcase) {
Expand All @@ -45,7 +45,7 @@ export function getMetricData(
} else if (metricName.includes('"') || metricName.includes("'")) {
return getMetricDataFromExpression(metricName, {
reducerIDs,
calculateOptions,
calculationOptions,
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/utils/metricData/getMetricDataFromExpression.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ describe("getMetricDataFromExpression", () => {
it("don't calculate null", () => {
expect(
getMetricDataFromExpression("'series-null' + 2", {
calculateOptions: { shouldCalculateNull: true },
calculationOptions: { shouldCalculateNull: true },
})
).toStrictEqual({
calcs: {
Expand Down Expand Up @@ -209,7 +209,7 @@ describe("getMetricDataFromExpression", () => {
it("don't calculate boolean", () => {
expect(
getMetricDataFromExpression("'series-boolean' + 2", {
calculateOptions: { shouldCalculateBoolean: true },
calculationOptions: { shouldCalculateBoolean: true },
})
).toStrictEqual({
calcs: {
Expand Down
18 changes: 11 additions & 7 deletions src/utils/metricData/getMetricDataFromExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
getMetricDataFromName,
} from "./getMetricDataFromName";

export interface CalculateOptions {
export interface CalculationOptions {
/**
* Calculate null values
*
Expand Down Expand Up @@ -59,7 +59,7 @@ export interface CalculateOptions {
function getCalcs({
metricExpression,
metricsData,
calculateOptions = {
calculationOptions = {
shouldCalculateNull: false,
shouldCalculateBoolean: false,
},
Expand All @@ -68,9 +68,9 @@ function getCalcs({
metricsData: {
[key: string]: MetricData;
};
calculateOptions?: CalculateOptions;
calculationOptions?: CalculationOptions;
}) {
const { shouldCalculateNull, shouldCalculateBoolean } = calculateOptions;
const { shouldCalculateNull, shouldCalculateBoolean } = calculationOptions;

// Get all unique calcs keys
const calcKeys = [
Expand Down Expand Up @@ -150,7 +150,7 @@ function getTime({

export interface MetricDataFromExpressionOptions
extends MetricDataFromNameOptions {
calculateOptions?: CalculateOptions;
calculationOptions?: CalculationOptions;
}

/**
Expand All @@ -161,7 +161,7 @@ export interface MetricDataFromExpressionOptions
*/
export function getMetricDataFromExpression(
metricExpression: string,
{ reducerIDs, calculateOptions }: MetricDataFromExpressionOptions = {}
{ reducerIDs, calculationOptions }: MetricDataFromExpressionOptions = {}
): MetricData {
const metricNames = metricExpression.match(/["']([^"']*)["']/g);

Expand All @@ -177,7 +177,11 @@ export function getMetricDataFromExpression(

if (!metricsData) return { calcs: {}, time: {}, hasData: false };

const calcs = getCalcs({ metricExpression, metricsData, calculateOptions });
const calcs = getCalcs({
metricExpression,
metricsData,
calculationOptions: calculationOptions,
});

const hasData = Object.keys(calcs).length > 0;

Expand Down

0 comments on commit c0ac318

Please sign in to comment.