Skip to content

Commit

Permalink
Renamed 'positive rate' to 'counter rate'
Browse files Browse the repository at this point in the history
  • Loading branch information
dbatchunag committed Oct 18, 2020
1 parent 162cf2e commit 9f01967
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 35 deletions.
4 changes: 2 additions & 2 deletions src/plugins/vis_type_timeseries/common/agg_lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ export const lookup = {
defaultMessage: 'Static Value',
}),
top_hit: i18n.translate('visTypeTimeseries.aggLookup.topHitLabel', { defaultMessage: 'Top Hit' }),
positive_rate: i18n.translate('visTypeTimeseries.aggLookup.positiveRateLabel', {
defaultMessage: 'Positive Rate',
counter_rate: i18n.translate('visTypeTimeseries.aggLookup.positiveRateLabel', {
defaultMessage: 'Counter Rate',
}),
};

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/vis_type_timeseries/common/calculate_label.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ export function calculateLabel(metric, metrics) {
defaultMessage: 'Filter Ratio',
});
}
if (metric.type === 'positive_rate') {
if (metric.type === 'counter_rate') {
return i18n.translate('visTypeTimeseries.calculateLabel.positiveRateLabel', {
defaultMessage: 'Positive Rate of {field}',
defaultMessage: 'Counter Rate of {field}',
values: { field: metric.field },
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ describe('TSVB AggSelect', () => {
"value": "count",
},
Object {
"label": "Positive Rate",
"value": "positive_rate",
"label": "Counter Rate",
"value": "counter_rate",
},
Object {
"label": "Max",
Expand Down Expand Up @@ -131,8 +131,8 @@ describe('TSVB AggSelect', () => {
"value": "filter_ratio",
},
Object {
"label": "Positive Rate",
"value": "positive_rate",
"label": "Counter Rate",
"value": "counter_rate",
},
Object {
"label": "Max",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ const metricAggs: AggSelectOption[] = [
},
{
label: i18n.translate('visTypeTimeseries.aggSelect.metricsAggs.positiveRateLabel', {
defaultMessage: 'Positive Rate',
defaultMessage: 'Counter Rate',
}),
value: 'positive_rate',
value: 'counter_rate',
},
{
label: i18n.translate('visTypeTimeseries.aggSelect.metricsAggs.maxLabel', {
Expand Down Expand Up @@ -229,7 +229,7 @@ const FILTER_RATIO_AGGS = [
'avg',
'cardinality',
'count',
'positive_rate',
'counter_rate',
'max',
'min',
'sum',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const UNIT_OPTIONS = [
},
];

export const PositiveRateAgg = (props) => {
export const CounterRateAgg = (props) => {
const defaults = { unit: '' };
const model = { ...defaults, ...props.model };

Expand Down Expand Up @@ -178,7 +178,7 @@ export const PositiveRateAgg = (props) => {
);
};

PositiveRateAgg.propTypes = {
CounterRateAgg.propTypes = {
disableDelete: PropTypes.bool,
fields: PropTypes.object,
model: PropTypes.object,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('TSVB Filter Ratio', () => {
};
shouldNotHaveHistogramField('max');
shouldNotHaveHistogramField('min');
shouldNotHaveHistogramField('positive_rate');
shouldNotHaveHistogramField('counter_rate');

it(`should not have histogram fields for cardinality`, () => {
const metric = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ describe('Histogram Types', () => {
shouldNotHaveHistogramSupport('variance');
shouldNotHaveHistogramSupport('sum_of_squares');
shouldNotHaveHistogramSupport('std_deviation');
shouldNotHaveHistogramSupport('positive_rate');
shouldNotHaveHistogramSupport('counter_rate');
shouldNotHaveHistogramSupport('top_hit');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { PercentileRankAgg } from '../aggs/percentile_rank';
import { Static } from '../aggs/static';
import { MathAgg } from '../aggs/math';
import { TopHitAgg } from '../aggs/top_hit';
import { PositiveRateAgg } from '../aggs/positive_rate';
import { CounterRateAgg } from '../aggs/counter_rate';

export const aggToComponent = {
count: StandardAgg,
Expand Down Expand Up @@ -66,5 +66,5 @@ export const aggToComponent = {
static: Static,
math: MathAgg,
top_hit: TopHitAgg,
positive_rate: PositiveRateAgg,
counter_rate: CounterRateAgg,
};
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('getSupportedFieldsByMetricType', () => {
shouldHaveHistogramAndNumbers('avg');
shouldHaveHistogramAndNumbers('sum');

shouldHaveOnlyNumbers('positive_rate');
shouldHaveOnlyNumbers('counter_rate');
shouldHaveOnlyNumbers('std_deviation');
shouldHaveOnlyNumbers('max');
shouldHaveOnlyNumbers('min');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import { getIntervalAndTimefield } from '../../get_interval_and_timefield';
import { bucketTransform } from '../../helpers/bucket_transform';
import { overwrite } from '../../helpers';

export const filter = (metric) => metric.type === 'positive_rate';
export const filter = (metric) => metric.type === 'counter_rate';

export const createPositiveRate = (doc, intervalString, aggRoot) => (metric) => {
export const createCounterRate = (doc, intervalString, aggRoot) => (metric) => {
const maxFn = bucketTransform.max;
const derivativeFn = bucketTransform.derivative;
const positiveOnlyFn = bucketTransform.positive_only;
Expand Down Expand Up @@ -57,14 +57,14 @@ export const createPositiveRate = (doc, intervalString, aggRoot) => (metric) =>
overwrite(doc, `${aggRoot}.timeseries.aggs.${metric.id}`, positiveOnlyBucket);
};

export function positiveRate(req, panel, series, esQueryConfig, indexPatternObject, capabilities) {
export function counterRate(req, panel, series, esQueryConfig, indexPatternObject, capabilities) {
return (next) => (doc) => {
const { interval } = getIntervalAndTimefield(panel, series, indexPatternObject);
const { intervalString } = getBucketSize(req, interval, capabilities);
if (series.metrics.some(filter)) {
series.metrics
.filter(filter)
.forEach(createPositiveRate(doc, intervalString, `aggs.${series.id}.aggs`));
.forEach(createCounterRate(doc, intervalString, `aggs.${series.id}.aggs`));
return next(doc);
}
return next(doc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* under the License.
*/

import { positiveRate } from './positive_rate';
describe('positiveRate(req, panel, series)', () => {
import { counterRate } from './counter_rate';
describe('counterRate(req, panel, series)', () => {
let panel;
let series;
let req;
Expand All @@ -34,7 +34,7 @@ describe('positiveRate(req, panel, series)', () => {
metrics: [
{
id: 'metric-1',
type: 'positive_rate',
type: 'counter_rate',
field: 'system.network.out.bytes',
unit: '1s',
},
Expand All @@ -52,13 +52,13 @@ describe('positiveRate(req, panel, series)', () => {

test('calls next when finished', () => {
const next = jest.fn();
positiveRate(req, panel, series)(next)({});
counterRate(req, panel, series)(next)({});
expect(next.mock.calls.length).toEqual(1);
});

test('returns positive rate aggs', () => {
test('returns counter rate aggs', () => {
const next = (doc) => doc;
const doc = positiveRate(req, panel, series)(next)({});
const doc = counterRate(req, panel, series)(next)({});
expect(doc).toEqual({
aggs: {
test: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { dateHistogram } from './date_histogram';
import { metricBuckets } from './metric_buckets';
import { siblingBuckets } from './sibling_buckets';
import { ratios as filterRatios } from './filter_ratios';
import { positiveRate } from './positive_rate';
import { counterRate } from './counter_rate';
import { normalizeQuery } from './normalize_query';

export const processors = [
Expand All @@ -39,6 +39,6 @@ export const processors = [
metricBuckets,
siblingBuckets,
filterRatios,
positiveRate,
counterRate,
normalizeQuery,
];
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
import { getBucketSize } from '../../helpers/get_bucket_size';
import { getIntervalAndTimefield } from '../../get_interval_and_timefield';
import { calculateAggRoot } from './calculate_agg_root';
import { createPositiveRate, filter } from '../series/positive_rate';
import { createCounterRate, filter } from '../series/counter_rate';

export function positiveRate(req, panel, esQueryConfig, indexPatternObject) {
export function counterRate(req, panel, esQueryConfig, indexPatternObject) {
return (next) => (doc) => {
const { interval } = getIntervalAndTimefield(panel, {}, indexPatternObject);
const { intervalString } = getBucketSize(req, interval);
panel.series.forEach((column) => {
const aggRoot = calculateAggRoot(doc, column);
column.metrics.filter(filter).forEach(createPositiveRate(doc, intervalString, aggRoot));
column.metrics.filter(filter).forEach(createCounterRate(doc, intervalString, aggRoot));
});
return next(doc);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { metricBuckets } from './metric_buckets';
import { siblingBuckets } from './sibling_buckets';
import { ratios as filterRatios } from './filter_ratios';
import { normalizeQuery } from './normalize_query';
import { positiveRate } from './positive_rate';
import { counterRate } from './counter_rate';

export const processors = [
query,
Expand All @@ -37,6 +37,6 @@ export const processors = [
metricBuckets,
siblingBuckets,
filterRatios,
positiveRate,
counterRate,
normalizeQuery,
];

0 comments on commit 9f01967

Please sign in to comment.