From 3999afbf9330ea978b99de5a7625cceeda88b8f3 Mon Sep 17 00:00:00 2001 From: Pete Harverson Date: Wed, 25 Sep 2019 14:52:42 +0100 Subject: [PATCH] [ML] Rename MlTimeBuckets to TimeBuckets --- .../datavisualizer/index_based/page.tsx | 4 +-- .../plugins/ml/public/explorer/explorer.js | 14 ++++----- .../explorer_chart_distribution.js | 4 +-- .../explorer_chart_distribution.test.js | 6 ++-- .../explorer_chart_single_metric.js | 4 +-- .../explorer_chart_single_metric.test.js | 6 ++-- .../explorer_charts_container.test.js | 6 ++-- .../ml/public/explorer/explorer_controller.js | 4 +-- .../explorer_react_wrapper_directive.js | 2 +- .../ml/public/explorer/explorer_swimlane.js | 6 ++-- .../public/explorer/explorer_swimlane.test.js | 20 ++++++------- .../event_rate_chart_directive.js | 4 +-- .../components/utils/chart_data_utils.js | 4 +-- .../create_job/create_job_chart_directive.js | 4 +-- .../create_job/create_job_controller.js | 4 +-- .../create_job/create_job_chart_directive.js | 4 +-- .../create_job/create_job_controller.js | 4 +-- .../create_job/create_job_service.js | 6 ++-- .../create_job/create_job_chart_directive.js | 4 +-- .../create_job/create_job_controller.js | 4 +-- .../common/results_loader/results_loader.ts | 6 ++-- .../components/charts/common/settings.ts | 8 ++--- .../pages/components/job_creator_context.ts | 6 ++-- .../jobs/new_job_new/pages/new_job/page.tsx | 4 +-- .../jobs/new_job_new/pages/new_job/wizard.tsx | 4 +-- .../timeseries_chart/timeseries_chart.js | 6 ++-- .../timeseries_chart/timeseries_chart.test.js | 4 +-- .../timeseriesexplorer/timeseriesexplorer.js | 2 +- .../timeseriesexplorer_utils.js | 6 ++-- ...auto_interval.js => calc_auto_interval.js} | 2 +- .../public/util/__tests__/ml_time_buckets.js | 8 ++--- ...auto_interval.js => calc_auto_interval.js} | 0 ...ml_time_buckets.d.ts => time_buckets.d.ts} | 2 +- .../{ml_time_buckets.js => time_buckets.js} | 30 +++++++++---------- 34 files changed, 101 insertions(+), 101 deletions(-) rename x-pack/legacy/plugins/ml/public/util/__tests__/{ml_calc_auto_interval.js => calc_auto_interval.js} (98%) rename x-pack/legacy/plugins/ml/public/util/{ml_calc_auto_interval.js => calc_auto_interval.js} (100%) rename x-pack/legacy/plugins/ml/public/util/{ml_time_buckets.d.ts => time_buckets.d.ts} (95%) rename x-pack/legacy/plugins/ml/public/util/{ml_time_buckets.js => time_buckets.js} (92%) diff --git a/x-pack/legacy/plugins/ml/public/datavisualizer/index_based/page.tsx b/x-pack/legacy/plugins/ml/public/datavisualizer/index_based/page.tsx index 1291d169f8365..e2837ea9de1fc 100644 --- a/x-pack/legacy/plugins/ml/public/datavisualizer/index_based/page.tsx +++ b/x-pack/legacy/plugins/ml/public/datavisualizer/index_based/page.tsx @@ -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'; @@ -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; diff --git a/x-pack/legacy/plugins/ml/public/explorer/explorer.js b/x-pack/legacy/plugins/ml/public/explorer/explorer.js index 44f0f80d835a0..87900403fa685 100644 --- a/x-pack/legacy/plugins/ml/public/explorer/explorer.js +++ b/x-pack/legacy/plugins/ml/public/explorer/explorer.js @@ -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'; @@ -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(); @@ -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); @@ -1074,7 +1074,7 @@ export const Explorer = injectI18n(injectObservablesAsProps( globalState, intl, jobSelectService, - MlTimeBuckets, + TimeBuckets, } = this.props; const { @@ -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} @@ -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} diff --git a/x-pack/legacy/plugins/ml/public/explorer/explorer_charts/explorer_chart_distribution.js b/x-pack/legacy/plugins/ml/public/explorer/explorer_charts/explorer_chart_distribution.js index 38829ab7de084..67efbb848b193 100644 --- a/x-pack/legacy/plugins/ml/public/explorer/explorer_charts/explorer_chart_distribution.js +++ b/x-pack/legacy/plugins/ml/public/explorer/explorer_charts/explorer_chart_distribution.js @@ -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'; @@ -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'); diff --git a/x-pack/legacy/plugins/ml/public/explorer/explorer_charts/explorer_chart_distribution.test.js b/x-pack/legacy/plugins/ml/public/explorer/explorer_charts/explorer_chart_distribution.test.js index 36123a9e376bd..4e083fafa97ac 100644 --- a/x-pack/legacy/plugins/ml/public/explorer/explorer_charts/explorer_chart_distribution.test.js +++ b/x-pack/legacy/plugins/ml/public/explorer/explorer_charts/explorer_chart_distribution.test.js @@ -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(); diff --git a/x-pack/legacy/plugins/ml/public/explorer/explorer_charts/explorer_chart_single_metric.js b/x-pack/legacy/plugins/ml/public/explorer/explorer_charts/explorer_chart_single_metric.js index b74636f52c165..f7e05924f9e6a 100644 --- a/x-pack/legacy/plugins/ml/public/explorer/explorer_charts/explorer_chart_single_metric.js +++ b/x-pack/legacy/plugins/ml/public/explorer/explorer_charts/explorer_chart_single_metric.js @@ -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'; @@ -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'); diff --git a/x-pack/legacy/plugins/ml/public/explorer/explorer_charts/explorer_chart_single_metric.test.js b/x-pack/legacy/plugins/ml/public/explorer/explorer_charts/explorer_chart_single_metric.test.js index f81c22e24beb2..83d4fda0858a2 100644 --- a/x-pack/legacy/plugins/ml/public/explorer/explorer_charts/explorer_chart_single_metric.test.js +++ b/x-pack/legacy/plugins/ml/public/explorer/explorer_charts/explorer_chart_single_metric.test.js @@ -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(); diff --git a/x-pack/legacy/plugins/ml/public/explorer/explorer_charts/explorer_charts_container.test.js b/x-pack/legacy/plugins/ml/public/explorer/explorer_charts/explorer_charts_container.test.js index 4727f50a884a9..fc660f543b2cc 100644 --- a/x-pack/legacy/plugins/ml/public/explorer/explorer_charts/explorer_charts_container.test.js +++ b/x-pack/legacy/plugins/ml/public/explorer/explorer_charts/explorer_charts_container.test.js @@ -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(); diff --git a/x-pack/legacy/plugins/ml/public/explorer/explorer_controller.js b/x-pack/legacy/plugins/ml/public/explorer/explorer_controller.js index 693c884a7bb90..65da5382eef66 100644 --- a/x-pack/legacy/plugins/ml/public/explorer/explorer_controller.js +++ b/x-pack/legacy/plugins/ml/public/explorer/explorer_controller.js @@ -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'; @@ -74,7 +74,7 @@ module.controller('MlExplorerController', function ( timefilter.enableTimeRangeSelector(); timefilter.enableAutoRefreshSelector(); - $scope.MlTimeBuckets = MlTimeBuckets; + $scope.TimeBuckets = TimeBuckets; let resizeTimeout = null; diff --git a/x-pack/legacy/plugins/ml/public/explorer/explorer_react_wrapper_directive.js b/x-pack/legacy/plugins/ml/public/explorer/explorer_react_wrapper_directive.js index 0f6a8dcaa0b5a..40213a0649667 100644 --- a/x-pack/legacy/plugins/ml/public/explorer/explorer_react_wrapper_directive.js +++ b/x-pack/legacy/plugins/ml/public/explorer/explorer_react_wrapper_directive.js @@ -39,7 +39,7 @@ module.directive('mlExplorerReactWrapper', function (config, globalState) { dateFormatTz, globalState, jobSelectService, - MlTimeBuckets: scope.MlTimeBuckets, + TimeBuckets: scope.TimeBuckets, }} /> , diff --git a/x-pack/legacy/plugins/ml/public/explorer/explorer_swimlane.js b/x-pack/legacy/plugins/ml/public/explorer/explorer_swimlane.js index a61345176bb0e..2802f9775cf42 100644 --- a/x-pack/legacy/plugins/ml/public/explorer/explorer_swimlane.js +++ b/x-pack/legacy/plugins/ml/public/explorer/explorer_swimlane.js @@ -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 @@ -248,7 +248,7 @@ export const ExplorerSwimlane = injectI18n(class ExplorerSwimlane extends React. chartWidth, filterActive, maskAll, - MlTimeBuckets, + TimeBuckets, swimlaneCellClick, swimlaneData, swimlaneType, @@ -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(); diff --git a/x-pack/legacy/plugins/ml/public/explorer/explorer_swimlane.test.js b/x-pack/legacy/plugins/ml/public/explorer/explorer_swimlane.test.js index 6071e88cfc890..7063368bc2fe4 100644 --- a/x-pack/legacy/plugins/ml/public/explorer/explorer_swimlane.test.js +++ b/x-pack/legacy/plugins/ml/public/explorer/explorer_swimlane.test.js @@ -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 }; } @@ -65,7 +65,7 @@ describe('ExplorerSwimlane', () => { const wrapper = mountWithIntl( { // 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); }); @@ -91,7 +91,7 @@ describe('ExplorerSwimlane', () => { const wrapper = mountWithIntl( { // 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); }); }); diff --git a/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/components/event_rate_chart/event_rate_chart_directive.js b/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/components/event_rate_chart/event_rate_chart_directive.js index ec2542b7cca94..197a4b7605155 100644 --- a/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/components/event_rate_chart/event_rate_chart_directive.js +++ b/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/components/event_rate_chart/event_rate_chart_directive.js @@ -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'; @@ -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(); diff --git a/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/components/utils/chart_data_utils.js b/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/components/utils/chart_data_utils.js index 24aedb95acaa6..eb7aff0e702b3 100644 --- a/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/components/utils/chart_data_utils.js +++ b/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/components/utils/chart_data_utils.js @@ -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'; @@ -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'); diff --git a/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/multi_metric/create_job/create_job_chart_directive.js b/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/multi_metric/create_job/create_job_chart_directive.js index 2b23ca6447235..0fddf214eaa40 100644 --- a/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/multi_metric/create_job/create_job_chart_directive.js +++ b/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/multi_metric/create_job/create_job_chart_directive.js @@ -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'; @@ -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(); diff --git a/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/multi_metric/create_job/create_job_controller.js b/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/multi_metric/create_job/create_job_controller.js index 533188705ee01..8800730736dcd 100644 --- a/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/multi_metric/create_job/create_job_controller.js +++ b/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/multi_metric/create_job/create_job_controller.js @@ -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'; @@ -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'); diff --git a/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/population/create_job/create_job_chart_directive.js b/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/population/create_job/create_job_chart_directive.js index 62fa3c3f37ea2..e02d28f35ff2b 100644 --- a/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/population/create_job/create_job_chart_directive.js +++ b/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/population/create_job/create_job_chart_directive.js @@ -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'; @@ -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(); diff --git a/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/population/create_job/create_job_controller.js b/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/population/create_job/create_job_controller.js index 6d02f1219be64..67d6379c8ee88 100644 --- a/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/population/create_job/create_job_controller.js +++ b/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/population/create_job/create_job_controller.js @@ -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'; @@ -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'); diff --git a/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/population/create_job/create_job_service.js b/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/population/create_job/create_job_service.js index f4d1f8a2d462a..ae909a103097a 100644 --- a/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/population/create_job/create_job_service.js +++ b/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/population/create_job/create_job_service.js @@ -10,7 +10,7 @@ import _ from 'lodash'; import { EVENT_RATE_COUNT_FIELD, WIZARD_TYPE } from 'plugins/ml/jobs/new_job/simple/components/constants/general'; import { ML_MEDIAN_PERCENTS } from 'plugins/ml/../common/util/job_utils'; -import { MlTimeBuckets } from 'plugins/ml/util/ml_time_buckets'; +import { TimeBuckets } from 'plugins/ml/util/time_buckets'; import { mlFieldFormatService } from 'plugins/ml/services/field_format_service'; import { mlJobService } from 'plugins/ml/services/job_service'; import { createJobForSaving } from 'plugins/ml/jobs/new_job/utils/new_job_utils'; @@ -76,7 +76,7 @@ export function PopulationJobServiceProvider() { }; }); - const searchJson = getSearchJsonFromConfig(formConfig, timefilter, MlTimeBuckets); + const searchJson = getSearchJsonFromConfig(formConfig, timefilter, TimeBuckets); ml.esSearch(searchJson) .then((resp) => { @@ -313,7 +313,7 @@ export function PopulationJobServiceProvider() { function getSearchJsonFromConfig(formConfig) { const bounds = timefilter.getActiveBounds(); - const buckets = new MlTimeBuckets(); + const buckets = new TimeBuckets(); buckets.setInterval('auto'); buckets.setBounds(bounds); diff --git a/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/create_job_chart_directive.js b/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/create_job_chart_directive.js index f5b2a329a2435..a06fd3837a21f 100644 --- a/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/create_job_chart_directive.js +++ b/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/create_job_chart_directive.js @@ -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'; @@ -129,7 +129,7 @@ module.directive('mlSingleMetricJobChart', function () { lineChartXScale = lineChartXScale.domain(d3.extent(data, d => d.date)); // 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(); diff --git a/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/create_job_controller.js b/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/create_job_controller.js index b3a5ea0a51d63..954e9c49cc9ff 100644 --- a/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/create_job_controller.js +++ b/x-pack/legacy/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/create_job_controller.js @@ -22,7 +22,7 @@ import { subscribeWithScope } from 'ui/utils/subscribe_with_scope'; import { getSafeAggregationName } from 'plugins/ml/../common/util/job_utils'; 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 { getCreateSingleMetricJobBreadcrumbs } 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'; @@ -288,7 +288,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'); diff --git a/x-pack/legacy/plugins/ml/public/jobs/new_job_new/common/results_loader/results_loader.ts b/x-pack/legacy/plugins/ml/public/jobs/new_job_new/common/results_loader/results_loader.ts index 7adf84b54c4eb..8f593ce411b45 100644 --- a/x-pack/legacy/plugins/ml/public/jobs/new_job_new/common/results_loader/results_loader.ts +++ b/x-pack/legacy/plugins/ml/public/jobs/new_job_new/common/results_loader/results_loader.ts @@ -8,7 +8,7 @@ import { BehaviorSubject } from 'rxjs'; import { parseInterval } from 'ui/utils/parse_interval'; import { JobCreatorType, isMultiMetricJobCreator } from '../job_creator'; import { mlResultsService, ModelPlotOutputResults } from '../../../../services/results_service'; -import { MlTimeBuckets } from '../../../../util/ml_time_buckets'; +import { TimeBuckets } from '../../../../util/time_buckets'; import { getSeverityType } from '../../../../../common/util/anomaly_utils'; import { ANOMALY_SEVERITY } from '../../../../../common/constants/anomalies'; import { getScoresByRecord } from './searches'; @@ -55,7 +55,7 @@ export class ResultsLoader { private _results$: BehaviorSubject; private _resultsSearchRunning = false; private _jobCreator: JobCreatorType; - private _chartInterval: MlTimeBuckets; + private _chartInterval: TimeBuckets; private _lastModelTimeStamp: number = 0; private _lastResultsTimeout: any = null; private _chartLoader: ChartLoader; @@ -69,7 +69,7 @@ export class ResultsLoader { private _detectorSplitFieldFilters: SplitFieldWithValue | null = null; private _splitFieldFiltersLoaded: boolean = false; - constructor(jobCreator: JobCreatorType, chartInterval: MlTimeBuckets, chartLoader: ChartLoader) { + constructor(jobCreator: JobCreatorType, chartInterval: TimeBuckets, chartLoader: ChartLoader) { this._jobCreator = jobCreator; this._chartInterval = chartInterval; this._results$ = new BehaviorSubject(this._results); diff --git a/x-pack/legacy/plugins/ml/public/jobs/new_job_new/pages/components/charts/common/settings.ts b/x-pack/legacy/plugins/ml/public/jobs/new_job_new/pages/components/charts/common/settings.ts index 8e8bd8530c08a..b1852cbb259c1 100644 --- a/x-pack/legacy/plugins/ml/public/jobs/new_job_new/pages/components/charts/common/settings.ts +++ b/x-pack/legacy/plugins/ml/public/jobs/new_job_new/pages/components/charts/common/settings.ts @@ -12,7 +12,7 @@ import { isMultiMetricJobCreator, isPopulationJobCreator, } from '../../../../common/job_creator'; -import { MlTimeBuckets } from '../../../../../../util/ml_time_buckets'; +import { TimeBuckets } from '../../../../../../util/time_buckets'; const IS_DARK_THEME = chrome.getUiSettingsClient().get('theme:darkMode'); const themeName = IS_DARK_THEME ? darkTheme : lightTheme; @@ -57,7 +57,7 @@ export const seriesStyle = { }, }; -export function getChartSettings(jobCreator: JobCreatorType, chartInterval: MlTimeBuckets) { +export function getChartSettings(jobCreator: JobCreatorType, chartInterval: TimeBuckets) { const cs = { ...defaultChartSettings, intervalMs: chartInterval.getInterval().asMilliseconds(), @@ -65,10 +65,10 @@ export function getChartSettings(jobCreator: JobCreatorType, chartInterval: MlTi if (isPopulationJobCreator(jobCreator)) { // for population charts, use a larger interval based on - // the calculation from MlTimeBuckets, but without the + // the calculation from TimeBuckets, but without the // bar target and max bars which have been set for the // general chartInterval - const interval = new MlTimeBuckets(); + const interval = new TimeBuckets(); interval.setInterval('auto'); interval.setBounds(chartInterval.getBounds()); cs.intervalMs = interval.getInterval().asMilliseconds(); diff --git a/x-pack/legacy/plugins/ml/public/jobs/new_job_new/pages/components/job_creator_context.ts b/x-pack/legacy/plugins/ml/public/jobs/new_job_new/pages/components/job_creator_context.ts index 76f9b66f42305..5fd3c98ed54c9 100644 --- a/x-pack/legacy/plugins/ml/public/jobs/new_job_new/pages/components/job_creator_context.ts +++ b/x-pack/legacy/plugins/ml/public/jobs/new_job_new/pages/components/job_creator_context.ts @@ -6,7 +6,7 @@ import { createContext } from 'react'; import { Field, Aggregation } from '../../../../../common/types/fields'; -import { MlTimeBuckets } from '../../../../util/ml_time_buckets'; +import { TimeBuckets } from '../../../../util/time_buckets'; import { JobCreatorType, SingleMetricJobCreator } from '../../common/job_creator'; import { ChartLoader } from '../../common/chart_loader'; import { ResultsLoader } from '../../common/results_loader'; @@ -19,7 +19,7 @@ export interface JobCreatorContextValue { jobCreator: JobCreatorType; chartLoader: ChartLoader; resultsLoader: ResultsLoader; - chartInterval: MlTimeBuckets; + chartInterval: TimeBuckets; jobValidator: JobValidator; jobValidatorUpdated: number; fields: Field[]; @@ -33,7 +33,7 @@ export const JobCreatorContext = createContext({ jobCreator: {} as SingleMetricJobCreator, chartLoader: {} as ChartLoader, resultsLoader: {} as ResultsLoader, - chartInterval: {} as MlTimeBuckets, + chartInterval: {} as TimeBuckets, jobValidator: {} as JobValidator, jobValidatorUpdated: 0, fields: [], diff --git a/x-pack/legacy/plugins/ml/public/jobs/new_job_new/pages/new_job/page.tsx b/x-pack/legacy/plugins/ml/public/jobs/new_job_new/pages/new_job/page.tsx index a3c249305d8e7..c5aa3c4269314 100644 --- a/x-pack/legacy/plugins/ml/public/jobs/new_job_new/pages/new_job/page.tsx +++ b/x-pack/legacy/plugins/ml/public/jobs/new_job_new/pages/new_job/page.tsx @@ -23,7 +23,7 @@ import { ResultsLoader } from '../../common/results_loader'; import { JobValidator } from '../../common/job_validator'; import { useKibanaContext } from '../../../../contexts/kibana'; import { getTimeFilterRange } from '../../../../components/full_time_range_selector'; -import { MlTimeBuckets } from '../../../../util/ml_time_buckets'; +import { TimeBuckets } from '../../../../util/time_buckets'; import { newJobDefaults } from '../../../new_job/utils/new_job_defaults'; import { ExistingJobsAndGroups, mlJobService } from '../../../../services/job_service'; import { expandCombinedJobConfig } from '../../common/job_creator/configs'; @@ -101,7 +101,7 @@ export const Page: FC = ({ existingJobsAndGroups, jobType }) => { } } - const chartInterval = new MlTimeBuckets(); + const chartInterval = new TimeBuckets(); chartInterval.setBarTarget(BAR_TARGET); chartInterval.setMaxBars(MAX_BARS); chartInterval.setInterval('auto'); diff --git a/x-pack/legacy/plugins/ml/public/jobs/new_job_new/pages/new_job/wizard.tsx b/x-pack/legacy/plugins/ml/public/jobs/new_job_new/pages/new_job/wizard.tsx index fcd1c4808a30a..7c573bfe85270 100644 --- a/x-pack/legacy/plugins/ml/public/jobs/new_job_new/pages/new_job/wizard.tsx +++ b/x-pack/legacy/plugins/ml/public/jobs/new_job_new/pages/new_job/wizard.tsx @@ -18,7 +18,7 @@ import { PickFieldsStep } from '../components/pick_fields_step'; import { JobDetailsStep } from '../components/job_details_step'; import { ValidationStep } from '../components/validation_step'; import { SummaryStep } from '../components/summary_step'; -import { MlTimeBuckets } from '../../../../util/ml_time_buckets'; +import { TimeBuckets } from '../../../../util/time_buckets'; import { useKibanaContext } from '../../../../contexts/kibana'; import { JobCreatorContext, JobCreatorContextValue } from '../components/job_creator_context'; @@ -34,7 +34,7 @@ interface Props { jobCreator: JobCreatorType; chartLoader: ChartLoader; resultsLoader: ResultsLoader; - chartInterval: MlTimeBuckets; + chartInterval: TimeBuckets; jobValidator: JobValidator; existingJobsAndGroups: ExistingJobsAndGroups; skipTimeRangeStep: boolean; diff --git a/x-pack/legacy/plugins/ml/public/timeseriesexplorer/components/timeseries_chart/timeseries_chart.js b/x-pack/legacy/plugins/ml/public/timeseriesexplorer/components/timeseries_chart/timeseries_chart.js index c976584ecd64b..1363342f81518 100644 --- a/x-pack/legacy/plugins/ml/public/timeseriesexplorer/components/timeseries_chart/timeseries_chart.js +++ b/x-pack/legacy/plugins/ml/public/timeseriesexplorer/components/timeseries_chart/timeseries_chart.js @@ -39,7 +39,7 @@ import { showMultiBucketAnomalyTooltip, } from '../../../util/chart_utils'; import { formatHumanReadableDateTimeSeconds } from '../../../util/date_utils'; -import { MlTimeBuckets } from '../../../util/ml_time_buckets'; +import { TimeBuckets } from '../../../util/time_buckets'; import { mlTableService } from '../../../services/table_service'; import { ContextChartMask } from '../context_chart_mask'; import { findChartPointForAnomalyTime } from '../../timeseriesexplorer_utils'; @@ -629,7 +629,7 @@ const TimeseriesChartIntl = injectI18n(class TimeseriesChart extends React.Compo } // Get the scaled date format to use for x axis tick labels. - const timeBuckets = new MlTimeBuckets(); + const timeBuckets = new TimeBuckets(); timeBuckets.setInterval('auto'); timeBuckets.setBounds(bounds); const xAxisTickFormat = timeBuckets.getScaledDateFormat(); @@ -916,7 +916,7 @@ const TimeseriesChartIntl = injectI18n(class TimeseriesChart extends React.Compo // Add x axis. const bounds = timefilter.getActiveBounds(); - const timeBuckets = new MlTimeBuckets(); + const timeBuckets = new TimeBuckets(); timeBuckets.setInterval('auto'); timeBuckets.setBounds(bounds); const xAxisTickFormat = timeBuckets.getScaledDateFormat(); diff --git a/x-pack/legacy/plugins/ml/public/timeseriesexplorer/components/timeseries_chart/timeseries_chart.test.js b/x-pack/legacy/plugins/ml/public/timeseriesexplorer/components/timeseries_chart/timeseries_chart.test.js index 20990c64f92a5..5d02273c4a85d 100644 --- a/x-pack/legacy/plugins/ml/public/timeseriesexplorer/components/timeseries_chart/timeseries_chart.test.js +++ b/x-pack/legacy/plugins/ml/public/timeseriesexplorer/components/timeseries_chart/timeseries_chart.test.js @@ -25,8 +25,8 @@ jest.mock('ui/chrome', () => ({ }), })); -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(); diff --git a/x-pack/legacy/plugins/ml/public/timeseriesexplorer/timeseriesexplorer.js b/x-pack/legacy/plugins/ml/public/timeseriesexplorer/timeseriesexplorer.js index 6b0babf5c3019..caef7be64d6e0 100644 --- a/x-pack/legacy/plugins/ml/public/timeseriesexplorer/timeseriesexplorer.js +++ b/x-pack/legacy/plugins/ml/public/timeseriesexplorer/timeseriesexplorer.js @@ -66,7 +66,7 @@ import { mlResultsService } from '../services/results_service'; import { mlTimefilterRefresh$ } from '../services/timefilter_refresh_service'; import { getIndexPatterns } from '../util/index_utils'; -import { getBoundsRoundedToInterval } from '../util/ml_time_buckets'; +import { getBoundsRoundedToInterval } from '../util/time_buckets'; import { APP_STATE_ACTION, CHARTS_POINT_TARGET, TIME_FIELD_NAME } from './timeseriesexplorer_constants'; import { mlTimeSeriesSearchService } from './timeseries_search_service'; diff --git a/x-pack/legacy/plugins/ml/public/timeseriesexplorer/timeseriesexplorer_utils.js b/x-pack/legacy/plugins/ml/public/timeseriesexplorer/timeseriesexplorer_utils.js index 7a50b52c191a3..ac5d829ded3a9 100644 --- a/x-pack/legacy/plugins/ml/public/timeseriesexplorer/timeseriesexplorer_utils.js +++ b/x-pack/legacy/plugins/ml/public/timeseriesexplorer/timeseriesexplorer_utils.js @@ -29,7 +29,7 @@ import { import { ml } from '../services/ml_api_service'; import { mlForecastService } from '../services/forecast_service'; import { mlResultsService } from '../services/results_service'; -import { MlTimeBuckets, getBoundsRoundedToInterval } from '../util/ml_time_buckets'; +import { TimeBuckets, getBoundsRoundedToInterval } from '../util/time_buckets'; import { mlTimeSeriesSearchService } from './timeseries_search_service'; @@ -461,7 +461,7 @@ export function calculateAggregationInterval( const barTarget = (bucketsTarget !== undefined ? bucketsTarget : 100); // Use a maxBars of 10% greater than the target. const maxBars = Math.floor(1.1 * barTarget); - const buckets = new MlTimeBuckets(); + const buckets = new TimeBuckets(); buckets.setInterval('auto'); buckets.setBounds(bounds); buckets.setBarTarget(Math.floor(barTarget)); @@ -551,7 +551,7 @@ export function getAutoZoomDuration(jobs, selectedJob) { // Use a maxBars of 10% greater than the target. const maxBars = Math.floor(1.1 * CHARTS_POINT_TARGET); - const buckets = new MlTimeBuckets(); + const buckets = new TimeBuckets(); buckets.setInterval('auto'); buckets.setBarTarget(Math.floor(CHARTS_POINT_TARGET)); buckets.setMaxBars(maxBars); diff --git a/x-pack/legacy/plugins/ml/public/util/__tests__/ml_calc_auto_interval.js b/x-pack/legacy/plugins/ml/public/util/__tests__/calc_auto_interval.js similarity index 98% rename from x-pack/legacy/plugins/ml/public/util/__tests__/ml_calc_auto_interval.js rename to x-pack/legacy/plugins/ml/public/util/__tests__/calc_auto_interval.js index abc3fc7a462df..f89bb6aaffc48 100644 --- a/x-pack/legacy/plugins/ml/public/util/__tests__/ml_calc_auto_interval.js +++ b/x-pack/legacy/plugins/ml/public/util/__tests__/calc_auto_interval.js @@ -9,7 +9,7 @@ import expect from '@kbn/expect'; import moment from 'moment'; -import { timeBucketsCalcAutoIntervalProvider } from '../ml_calc_auto_interval'; +import { timeBucketsCalcAutoIntervalProvider } from '../calc_auto_interval'; describe('ML - calc auto intervals', () => { diff --git a/x-pack/legacy/plugins/ml/public/util/__tests__/ml_time_buckets.js b/x-pack/legacy/plugins/ml/public/util/__tests__/ml_time_buckets.js index a9b7e775b6704..de3ebf27517ff 100644 --- a/x-pack/legacy/plugins/ml/public/util/__tests__/ml_time_buckets.js +++ b/x-pack/legacy/plugins/ml/public/util/__tests__/ml_time_buckets.js @@ -10,9 +10,9 @@ import ngMock from 'ng_mock'; import expect from '@kbn/expect'; import moment from 'moment'; import { - MlTimeBuckets, + TimeBuckets, getBoundsRoundedToInterval, - calcEsInterval } from '../ml_time_buckets'; + calcEsInterval } from '../time_buckets'; describe('ML - time buckets', () => { @@ -23,10 +23,10 @@ describe('ML - time buckets', () => { ngMock.module('kibana'); ngMock.inject(() => { - autoBuckets = new MlTimeBuckets(); + autoBuckets = new TimeBuckets(); autoBuckets.setInterval('auto'); - customBuckets = new MlTimeBuckets(); + customBuckets = new TimeBuckets(); customBuckets.setInterval('auto'); customBuckets.setBarTarget(500); customBuckets.setMaxBars(550); diff --git a/x-pack/legacy/plugins/ml/public/util/ml_calc_auto_interval.js b/x-pack/legacy/plugins/ml/public/util/calc_auto_interval.js similarity index 100% rename from x-pack/legacy/plugins/ml/public/util/ml_calc_auto_interval.js rename to x-pack/legacy/plugins/ml/public/util/calc_auto_interval.js diff --git a/x-pack/legacy/plugins/ml/public/util/ml_time_buckets.d.ts b/x-pack/legacy/plugins/ml/public/util/time_buckets.d.ts similarity index 95% rename from x-pack/legacy/plugins/ml/public/util/ml_time_buckets.d.ts rename to x-pack/legacy/plugins/ml/public/util/time_buckets.d.ts index b860fdeeec8e2..17773b66e7456 100644 --- a/x-pack/legacy/plugins/ml/public/util/ml_time_buckets.d.ts +++ b/x-pack/legacy/plugins/ml/public/util/time_buckets.d.ts @@ -11,7 +11,7 @@ declare interface TimeFilterBounds { max: Moment; } -export class MlTimeBuckets { +export class TimeBuckets { setBarTarget: (barTarget: number) => void; setMaxBars: (maxBars: number) => void; setInterval: (interval: string) => void; diff --git a/x-pack/legacy/plugins/ml/public/util/ml_time_buckets.js b/x-pack/legacy/plugins/ml/public/util/time_buckets.js similarity index 92% rename from x-pack/legacy/plugins/ml/public/util/ml_time_buckets.js rename to x-pack/legacy/plugins/ml/public/util/time_buckets.js index e4ee9b35e64ee..2a4c7023dbb02 100644 --- a/x-pack/legacy/plugins/ml/public/util/ml_time_buckets.js +++ b/x-pack/legacy/plugins/ml/public/util/time_buckets.js @@ -11,7 +11,7 @@ import dateMath from '@elastic/datemath'; import chrome from 'ui/chrome'; import { fieldFormats } from 'ui/registry/field_formats'; -import { timeBucketsCalcAutoIntervalProvider } from './ml_calc_auto_interval'; +import { timeBucketsCalcAutoIntervalProvider } from './calc_auto_interval'; import { parseInterval } from '../../common/util/parse_interval'; const unitsDesc = dateMath.unitsDesc; @@ -28,7 +28,7 @@ const calcAuto = timeBucketsCalcAutoIntervalProvider(); * describes a timespan that will separate buckets of time, * for example the interval between points on a time series chart. */ -export function MlTimeBuckets() { +export function TimeBuckets() { this.barTarget = config.get('histogram:barTarget'); this.maxBars = config.get('histogram:maxBars'); } @@ -40,7 +40,7 @@ export function MlTimeBuckets() { * * @returns {undefined} */ -MlTimeBuckets.prototype.setBarTarget = function (bt) { +TimeBuckets.prototype.setBarTarget = function (bt) { this.barTarget = bt; }; @@ -51,7 +51,7 @@ MlTimeBuckets.prototype.setBarTarget = function (bt) { * * @returns {undefined} */ -MlTimeBuckets.prototype.setMaxBars = function (mb) { +TimeBuckets.prototype.setMaxBars = function (mb) { this.maxBars = mb; }; @@ -66,7 +66,7 @@ MlTimeBuckets.prototype.setMaxBars = function (mb) { * * @returns {undefined} */ -MlTimeBuckets.prototype.setBounds = function (input) { +TimeBuckets.prototype.setBounds = function (input) { if (!input) return this.clearBounds(); let bounds; @@ -99,7 +99,7 @@ MlTimeBuckets.prototype.setBounds = function (input) { * * @return {undefined} */ -MlTimeBuckets.prototype.clearBounds = function () { +TimeBuckets.prototype.clearBounds = function () { this._lb = this._ub = null; }; @@ -108,7 +108,7 @@ MlTimeBuckets.prototype.clearBounds = function () { * * @return {Boolean} */ -MlTimeBuckets.prototype.hasBounds = function () { +TimeBuckets.prototype.hasBounds = function () { return isValidMoment(this._ub) && isValidMoment(this._lb); }; @@ -124,7 +124,7 @@ MlTimeBuckets.prototype.hasBounds = function () { * min and max. Each property will be a moment() * object */ -MlTimeBuckets.prototype.getBounds = function () { +TimeBuckets.prototype.getBounds = function () { if (!this.hasBounds()) return; return { min: this._lb, @@ -139,7 +139,7 @@ MlTimeBuckets.prototype.getBounds = function () { * * @return {moment.duration|undefined} */ -MlTimeBuckets.prototype.getDuration = function () { +TimeBuckets.prototype.getDuration = function () { if (!this.hasBounds()) return; return moment.duration(this._ub - this._lb, 'ms'); }; @@ -156,7 +156,7 @@ MlTimeBuckets.prototype.getDuration = function () { * * @param {object|string|moment.duration} input - see desc */ -MlTimeBuckets.prototype.setInterval = function (input) { +TimeBuckets.prototype.setInterval = function (input) { // Preserve the original units because they're lost when the interval is converted to a // moment duration object. this.originalInterval = input; @@ -223,7 +223,7 @@ MlTimeBuckets.prototype.setInterval = function (input) { * * @return {[type]} [description] */ -MlTimeBuckets.prototype.getInterval = function () { +TimeBuckets.prototype.getInterval = function () { const self = this; const duration = self.getDuration(); return decorateInterval(maybeScaleInterval(readInterval()), duration); @@ -269,7 +269,7 @@ MlTimeBuckets.prototype.getInterval = function () { * * @return {moment.duration|undefined} */ -MlTimeBuckets.prototype.getIntervalToNearestMultiple = function (divisorSecs) { +TimeBuckets.prototype.getIntervalToNearestMultiple = function (divisorSecs) { const interval = this.getInterval(); const intervalSecs = interval.asSeconds(); @@ -307,7 +307,7 @@ MlTimeBuckets.prototype.getIntervalToNearestMultiple = function (divisorSecs) { * * @return {string} */ -MlTimeBuckets.prototype.getScaledDateFormat = function () { +TimeBuckets.prototype.getScaledDateFormat = function () { const interval = this.getInterval(); const rules = config.get('dateFormat:scaled'); @@ -321,14 +321,14 @@ MlTimeBuckets.prototype.getScaledDateFormat = function () { return config.get('dateFormat'); }; -MlTimeBuckets.prototype.getScaledDateFormatter = function () { +TimeBuckets.prototype.getScaledDateFormatter = function () { const DateFieldFormat = fieldFormats.getType('date'); return new DateFieldFormat({ pattern: this.getScaledDateFormat() }, getConfig); }; -// Appends some MlTimeBuckets specific properties to the moment.js duration interval. +// Appends some TimeBuckets specific properties to the moment.js duration interval. // Uses the originalDuration from which the time bucket was created to calculate the overflow // property (i.e. difference between the supplied duration and the calculated bucket interval). function decorateInterval(interval, originalDuration) {