Skip to content

Commit

Permalink
[ML] Rename MlTimeBuckets to TimeBuckets
Browse files Browse the repository at this point in the history
  • Loading branch information
peteharverson committed Sep 25, 2019
1 parent 6616bc7 commit 3999afb
Show file tree
Hide file tree
Showing 34 changed files with 101 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { useKibanaContext, SavedSearchQuery } from '../../contexts/kibana';
import { kbnTypeToMLJobType } from '../../util/field_types_utils';
// @ts-ignore
import { timeBasedIndexCheck } from '../../util/index_utils';
import { MlTimeBuckets } from '../../util/ml_time_buckets';
import { TimeBuckets } from '../../util/time_buckets';
import { FieldRequestConfig, FieldVisConfig } from './common';
import { ActionsPanel } from './components/actions_panel';
import { FieldsPanel } from './components/fields_panel';
Expand Down Expand Up @@ -269,7 +269,7 @@ export const Page: FC = () => {

// Obtain the interval to use for date histogram aggregations
// (such as the document count chart). Aim for 75 bars.
const buckets = new MlTimeBuckets();
const buckets = new TimeBuckets();

const tf = timefilter as any;
let earliest: number | undefined;
Expand Down
14 changes: 7 additions & 7 deletions x-pack/legacy/plugins/ml/public/explorer/explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
import { ExplorerSwimlane } from './explorer_swimlane';
import { KqlFilterBar } from '../components/kql_filter_bar';
import { formatHumanReadableDateTime } from '../util/date_utils';
import { getBoundsRoundedToInterval } from 'plugins/ml/util/ml_time_buckets';
import { getBoundsRoundedToInterval } from '../util/time_buckets';
import { getSelectedJobIds } from '../components/job_selector/job_select_service_utils';
import { InfluencersList } from '../components/influencers_list';
import { ALLOW_CELL_RANGE_SELECTION, dragSelect$, explorer$ } from './explorer_dashboard_service';
Expand Down Expand Up @@ -159,7 +159,7 @@ export const Explorer = injectI18n(injectObservablesAsProps(
dateFormatTz: PropTypes.string.isRequired,
globalState: PropTypes.object.isRequired,
jobSelectService: PropTypes.object.isRequired,
MlTimeBuckets: PropTypes.func.isRequired,
TimeBuckets: PropTypes.func.isRequired,
};

state = getExplorerDefaultState();
Expand Down Expand Up @@ -365,13 +365,13 @@ export const Explorer = injectI18n(injectObservablesAsProps(
}

getSwimlaneBucketInterval(selectedJobs) {
const { MlTimeBuckets } = this.props;
const { TimeBuckets } = this.props;

const swimlaneWidth = getSwimlaneContainerWidth(this.state.noInfluencersConfigured);
// Bucketing interval should be the maximum of the chart related interval (i.e. time range related)
// and the max bucket span for the jobs shown in the chart.
const bounds = timefilter.getActiveBounds();
const buckets = new MlTimeBuckets();
const buckets = new TimeBuckets();
buckets.setInterval('auto');
buckets.setBounds(bounds);

Expand Down Expand Up @@ -1074,7 +1074,7 @@ export const Explorer = injectI18n(injectObservablesAsProps(
globalState,
intl,
jobSelectService,
MlTimeBuckets,
TimeBuckets,
} = this.props;

const {
Expand Down Expand Up @@ -1206,7 +1206,7 @@ export const Explorer = injectI18n(injectObservablesAsProps(
chartWidth={swimlaneWidth}
filterActive={filterActive}
maskAll={maskAll}
MlTimeBuckets={MlTimeBuckets}
TimeBuckets={TimeBuckets}
swimlaneCellClick={this.swimlaneCellClick}
swimlaneData={overallSwimlaneData}
swimlaneType={SWIMLANE_TYPE.OVERALL}
Expand Down Expand Up @@ -1282,7 +1282,7 @@ export const Explorer = injectI18n(injectObservablesAsProps(
chartWidth={swimlaneWidth}
filterActive={filterActive}
maskAll={maskAll}
MlTimeBuckets={MlTimeBuckets}
TimeBuckets={TimeBuckets}
swimlaneCellClick={this.swimlaneCellClick}
swimlaneData={viewBySwimlaneData}
swimlaneType={SWIMLANE_TYPE.VIEW_BY}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
removeLabelOverlap
} from '../../util/chart_utils';
import { LoadingIndicator } from '../../components/loading_indicator/loading_indicator';
import { MlTimeBuckets } from '../../util/ml_time_buckets';
import { TimeBuckets } from '../../util/time_buckets';
import { mlEscape } from '../../util/string_utils';
import { mlFieldFormatService } from '../../services/field_format_service';
import { mlChartTooltipService } from '../../components/chart_tooltip/chart_tooltip_service';
Expand Down Expand Up @@ -248,7 +248,7 @@ export const ExplorerChartDistribution = injectI18n(class ExplorerChartDistribut

function drawRareChartAxes() {
// Get the scaled date format to use for x axis tick labels.
const timeBuckets = new MlTimeBuckets();
const timeBuckets = new TimeBuckets();
const bounds = { min: moment(config.plotEarliest), max: moment(config.plotLatest) };
timeBuckets.setBounds(bounds);
timeBuckets.setInterval('auto');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import './explorer_chart_distribution.test.mocks';
import { chartData as mockChartData } from './__mocks__/mock_chart_data_rare';
import seriesConfig from './__mocks__/mock_series_config_rare.json';

// Mock MlTimeBuckets and mlFieldFormatService, they don't play well
// Mock TimeBuckets and mlFieldFormatService, they don't play well
// with the jest based test setup yet.
jest.mock('../../util/ml_time_buckets', () => ({
MlTimeBuckets: function () {
jest.mock('../../util/time_buckets', () => ({
TimeBuckets: function () {
this.setBounds = jest.fn();
this.setInterval = jest.fn();
this.getScaledDateFormat = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
showMultiBucketAnomalyTooltip,
} from '../../util/chart_utils';
import { LoadingIndicator } from '../../components/loading_indicator/loading_indicator';
import { MlTimeBuckets } from '../../util/ml_time_buckets';
import { TimeBuckets } from '../../util/time_buckets';
import { mlEscape } from '../../util/string_utils';
import { mlFieldFormatService } from '../../services/field_format_service';
import { mlChartTooltipService } from '../../components/chart_tooltip/chart_tooltip_service';
Expand Down Expand Up @@ -187,7 +187,7 @@ export const ExplorerChartSingleMetric = injectI18n(class ExplorerChartSingleMet

function drawLineChartAxes() {
// Get the scaled date format to use for x axis tick labels.
const timeBuckets = new MlTimeBuckets();
const timeBuckets = new TimeBuckets();
const bounds = { min: moment(config.plotEarliest), max: moment(config.plotLatest) };
timeBuckets.setBounds(bounds);
timeBuckets.setInterval('auto');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import './explorer_chart_single_metric.test.mocks';
import { chartData as mockChartData } from './__mocks__/mock_chart_data';
import seriesConfig from './__mocks__/mock_series_config_filebeat.json';

// Mock MlTimeBuckets and mlFieldFormatService, they don't play well
// Mock TimeBuckets and mlFieldFormatService, they don't play well
// with the jest based test setup yet.
jest.mock('../../util/ml_time_buckets', () => ({
MlTimeBuckets: function () {
jest.mock('../../util/time_buckets', () => ({
TimeBuckets: function () {
this.setBounds = jest.fn();
this.setInterval = jest.fn();
this.getScaledDateFormat = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { chartData } from './__mocks__/mock_chart_data';
import seriesConfig from './__mocks__/mock_series_config_filebeat.json';
import seriesConfigRare from './__mocks__/mock_series_config_rare.json';

// Mock MlTimeBuckets and mlFieldFormatService, they don't play well
// Mock TimeBuckets and mlFieldFormatService, they don't play well
// with the jest based test setup yet.
jest.mock('../../util/ml_time_buckets', () => ({
MlTimeBuckets: function () {
jest.mock('../../util/time_buckets', () => ({
TimeBuckets: function () {
this.setBounds = jest.fn();
this.setInterval = jest.fn();
this.getScaledDateFormat = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { getAnomalyExplorerBreadcrumbs } from './breadcrumbs';
import { checkFullLicense } from '../license/check_license';
import { checkGetJobsPrivilege } from '../privilege/check_privilege';
import { getIndexPatterns, loadIndexPatterns } from '../util/index_utils';
import { MlTimeBuckets } from 'plugins/ml/util/ml_time_buckets';
import { TimeBuckets } from 'plugins/ml/util/time_buckets';
import { explorer$ } from './explorer_dashboard_service';
import { mlTimefilterRefresh$ } from '../services/timefilter_refresh_service';
import { mlFieldFormatService } from 'plugins/ml/services/field_format_service';
Expand Down Expand Up @@ -74,7 +74,7 @@ module.controller('MlExplorerController', function (
timefilter.enableTimeRangeSelector();
timefilter.enableAutoRefreshSelector();

$scope.MlTimeBuckets = MlTimeBuckets;
$scope.TimeBuckets = TimeBuckets;

let resizeTimeout = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.directive('mlExplorerReactWrapper', function (config, globalState) {
dateFormatTz,
globalState,
jobSelectService,
MlTimeBuckets: scope.MlTimeBuckets,
TimeBuckets: scope.TimeBuckets,
}}
/>
</I18nContext>,
Expand Down
6 changes: 3 additions & 3 deletions x-pack/legacy/plugins/ml/public/explorer/explorer_swimlane.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const ExplorerSwimlane = injectI18n(class ExplorerSwimlane extends React.
chartWidth: PropTypes.number.isRequired,
filterActive: PropTypes.bool,
maskAll: PropTypes.bool,
MlTimeBuckets: PropTypes.func.isRequired,
TimeBuckets: PropTypes.func.isRequired,
swimlaneCellClick: PropTypes.func.isRequired,
swimlaneData: PropTypes.shape({
laneLabels: PropTypes.array.isRequired
Expand Down Expand Up @@ -248,7 +248,7 @@ export const ExplorerSwimlane = injectI18n(class ExplorerSwimlane extends React.
chartWidth,
filterActive,
maskAll,
MlTimeBuckets,
TimeBuckets,
swimlaneCellClick,
swimlaneData,
swimlaneType,
Expand Down Expand Up @@ -285,7 +285,7 @@ export const ExplorerSwimlane = injectI18n(class ExplorerSwimlane extends React.
.range([0, xAxisWidth]);

// Get the scaled date format to use for x axis tick labels.
const timeBuckets = new MlTimeBuckets();
const timeBuckets = new TimeBuckets();
timeBuckets.setInterval(`${stepSecs}s`);
const xAxisTickFormat = timeBuckets.getScaledDateFormat();

Expand Down
20 changes: 10 additions & 10 deletions x-pack/legacy/plugins/ml/public/explorer/explorer_swimlane.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ jest.mock('./explorer_dashboard_service', () => ({
}));

function getExplorerSwimlaneMocks() {
const MlTimeBucketsMethods = {
const TimeBucketsMethods = {
setInterval: jest.fn(),
getScaledDateFormat: jest.fn()
};
const MlTimeBuckets = jest.fn(() => MlTimeBucketsMethods);
MlTimeBuckets.mockMethods = MlTimeBucketsMethods;
const TimeBuckets = jest.fn(() => TimeBucketsMethods);
TimeBuckets.mockMethods = TimeBucketsMethods;

const swimlaneData = { laneLabels: [] };

return {
MlTimeBuckets,
TimeBuckets,
swimlaneData
};
}
Expand All @@ -65,7 +65,7 @@ describe('ExplorerSwimlane', () => {

const wrapper = mountWithIntl(<ExplorerSwimlane.WrappedComponent
chartWidth={mockChartWidth}
MlTimeBuckets={mocks.MlTimeBuckets}
TimeBuckets={mocks.TimeBuckets}
swimlaneCellClick={jest.fn()}
swimlaneData={mocks.swimlaneData}
swimlaneType="overall"
Expand All @@ -80,8 +80,8 @@ describe('ExplorerSwimlane', () => {
// test calls to mock functions
expect(dragSelect$.subscribe.mock.calls.length).toBeGreaterThanOrEqual(1);
expect(wrapper.instance().dragSelectSubscriber.unsubscribe.mock.calls).toHaveLength(0);
expect(mocks.MlTimeBuckets.mockMethods.setInterval.mock.calls.length).toBeGreaterThanOrEqual(1);
expect(mocks.MlTimeBuckets.mockMethods.getScaledDateFormat.mock.calls.length).toBeGreaterThanOrEqual(1);
expect(mocks.TimeBuckets.mockMethods.setInterval.mock.calls.length).toBeGreaterThanOrEqual(1);
expect(mocks.TimeBuckets.mockMethods.getScaledDateFormat.mock.calls.length).toBeGreaterThanOrEqual(1);
expect(swimlaneRenderDoneListener.mock.calls.length).toBeGreaterThanOrEqual(1);
});

Expand All @@ -91,7 +91,7 @@ describe('ExplorerSwimlane', () => {

const wrapper = mountWithIntl(<ExplorerSwimlane.WrappedComponent
chartWidth={mockChartWidth}
MlTimeBuckets={mocks.MlTimeBuckets}
TimeBuckets={mocks.TimeBuckets}
swimlaneCellClick={jest.fn()}
swimlaneData={mockOverallSwimlaneData}
swimlaneType="overall"
Expand All @@ -103,8 +103,8 @@ describe('ExplorerSwimlane', () => {
// test calls to mock functions
expect(dragSelect$.subscribe.mock.calls.length).toBeGreaterThanOrEqual(1);
expect(wrapper.instance().dragSelectSubscriber.unsubscribe.mock.calls).toHaveLength(0);
expect(mocks.MlTimeBuckets.mockMethods.setInterval.mock.calls.length).toBeGreaterThanOrEqual(1);
expect(mocks.MlTimeBuckets.mockMethods.getScaledDateFormat.mock.calls.length).toBeGreaterThanOrEqual(1);
expect(mocks.TimeBuckets.mockMethods.setInterval.mock.calls.length).toBeGreaterThanOrEqual(1);
expect(mocks.TimeBuckets.mockMethods.getScaledDateFormat.mock.calls.length).toBeGreaterThanOrEqual(1);
expect(swimlaneRenderDoneListener.mock.calls.length).toBeGreaterThanOrEqual(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import d3 from 'd3';
import angular from 'angular';
import moment from 'moment';

import { MlTimeBuckets } from '../../../../../util/ml_time_buckets';
import { TimeBuckets } from '../../../../../util/time_buckets';
import { numTicksForDateFormat } from 'plugins/ml/util/chart_utils';

import { uiModules } from 'ui/modules';
Expand Down Expand Up @@ -145,7 +145,7 @@ module.directive('mlEventRateChart', function () {
]);

// Get the scaled date format to use for x axis tick labels.
const timeBuckets = new MlTimeBuckets();
const timeBuckets = new TimeBuckets();
timeBuckets.setInterval('auto');
if (data.length > 0) {
const xDomain = barChartXScale.domain();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// various util functions for populating the chartData object used by the job wizards

import _ from 'lodash';
import { MlTimeBuckets } from 'plugins/ml/util/ml_time_buckets';
import { TimeBuckets } from 'plugins/ml/util/time_buckets';
import { calculateTextWidth } from 'plugins/ml/util/string_utils';
import { mlResultsService } from 'plugins/ml/services/results_service';
import { mlSimpleJobSearchService } from 'plugins/ml/jobs/new_job/simple/components/utils/search_service';
Expand All @@ -24,7 +24,7 @@ export function ChartDataUtilsProvider() {
const MAX_BARS = BAR_TARGET + (BAR_TARGET / 100) * 100; // 100% larger that bar target
const query = formConfig.combinedQuery;
const bounds = timefilter.getActiveBounds();
const buckets = new MlTimeBuckets();
const buckets = new TimeBuckets();
buckets.setBarTarget(BAR_TARGET);
buckets.setMaxBars(MAX_BARS);
buckets.setInterval('auto');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import d3 from 'd3';
import angular from 'angular';
import moment from 'moment';

import { MlTimeBuckets } from '../../../../../util/ml_time_buckets';
import { TimeBuckets } from '../../../../../util/time_buckets';
import { drawLineChartDots, numTicksForDateFormat } from 'plugins/ml/util/chart_utils';

import { uiModules } from 'ui/modules';
Expand Down Expand Up @@ -135,7 +135,7 @@ module.directive('mlMultiMetricJobChart', function () {
]);

// Get the scaled date format to use for x axis tick labels.
const timeBuckets = new MlTimeBuckets();
const timeBuckets = new TimeBuckets();
timeBuckets.setInterval('auto');
if (data.length > 0) {
const xDomain = lineChartXScale.domain();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import uiRoutes from 'ui/routes';
import { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
import { checkLicenseExpired } from 'plugins/ml/license/check_license';
import { checkCreateJobsPrivilege } from 'plugins/ml/privilege/check_privilege';
import { MlTimeBuckets } from 'plugins/ml/util/ml_time_buckets';
import { TimeBuckets } from 'plugins/ml/util/time_buckets';
import { getCreateMultiMetricJobBreadcrumbs } from 'plugins/ml/jobs/breadcrumbs';
import { filterAggTypes } from 'plugins/ml/jobs/new_job/simple/components/utils/filter_agg_types';
import { validateJob } from 'plugins/ml/jobs/new_job/simple/components/utils/validate_job';
Expand Down Expand Up @@ -292,7 +292,7 @@ module
}

const bounds = timefilter.getActiveBounds();
$scope.formConfig.chartInterval = new MlTimeBuckets();
$scope.formConfig.chartInterval = new TimeBuckets();
$scope.formConfig.chartInterval.setBarTarget(BAR_TARGET);
$scope.formConfig.chartInterval.setMaxBars(MAX_BARS);
$scope.formConfig.chartInterval.setInterval('auto');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import angular from 'angular';
import moment from 'moment';

import { formatHumanReadableDateTime } from '../../../../../util/date_utils';
import { MlTimeBuckets } from '../../../../../util/ml_time_buckets';
import { TimeBuckets } from '../../../../../util/time_buckets';
import { numTicksForDateFormat } from '../../../../../util/chart_utils';
import { mlEscape } from '../../../../../util/string_utils';
import { mlChartTooltipService } from '../../../../../components/chart_tooltip/chart_tooltip_service';
Expand Down Expand Up @@ -145,7 +145,7 @@ module.directive('mlPopulationJobChart', function () {
]);

// Get the scaled date format to use for x axis tick labels.
const timeBuckets = new MlTimeBuckets();
const timeBuckets = new TimeBuckets();
timeBuckets.setInterval('auto');
if (data.length > 0) {
const xDomain = chartXScale.domain();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import angular from 'angular';
import uiRoutes from 'ui/routes';
import { checkLicenseExpired } from 'plugins/ml/license/check_license';
import { checkCreateJobsPrivilege } from 'plugins/ml/privilege/check_privilege';
import { MlTimeBuckets } from 'plugins/ml/util/ml_time_buckets';
import { TimeBuckets } from 'plugins/ml/util/time_buckets';
import { getCreatePopulationJobBreadcrumbs } from 'plugins/ml/jobs/breadcrumbs';
import { filterAggTypes } from 'plugins/ml/jobs/new_job/simple/components/utils/filter_agg_types';
import { validateJob } from 'plugins/ml/jobs/new_job/simple/components/utils/validate_job';
Expand Down Expand Up @@ -302,7 +302,7 @@ module
}

const bounds = timefilter.getActiveBounds();
$scope.formConfig.chartInterval = new MlTimeBuckets();
$scope.formConfig.chartInterval = new TimeBuckets();
$scope.formConfig.chartInterval.setBarTarget(BAR_TARGET);
$scope.formConfig.chartInterval.setMaxBars(MAX_BARS);
$scope.formConfig.chartInterval.setInterval('auto');
Expand Down
Loading

0 comments on commit 3999afb

Please sign in to comment.