mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
* [ML] Fixing issue with incorrect timezones in jobs list * refactoring min and max calculation * changes based on review * changing TimeStamp to Timestamp
This commit is contained in:
parent
06e597ef46
commit
2a95660bd1
5 changed files with 25 additions and 31 deletions
|
@ -14,6 +14,8 @@ import {
|
|||
} from '@elastic/eui';
|
||||
|
||||
import chrome from 'ui/chrome';
|
||||
import moment from 'moment';
|
||||
const TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss';
|
||||
|
||||
import { mlJobService } from 'plugins/ml/services/job_service';
|
||||
|
||||
|
@ -21,22 +23,18 @@ function getLink(location, jobs) {
|
|||
let from = 0;
|
||||
let to = 0;
|
||||
if (jobs.length === 1) {
|
||||
from = jobs[0].earliestTimeStamp.string;
|
||||
to = jobs[0].latestTimeStamp.string;
|
||||
from = jobs[0].earliestTimestampMs;
|
||||
to = jobs[0].latestTimestampMs;
|
||||
} else {
|
||||
const froms = jobs.map(j => j.earliestTimeStamp).sort((a, b) => a.unix > b.unix);
|
||||
const tos = jobs.map(j => j.latestTimeStamp).sort((a, b) => a.unix < b.unix);
|
||||
from = froms[0].string;
|
||||
to = tos[0].string;
|
||||
from = Math.min(...jobs.map(j => j.earliestTimestampMs));
|
||||
to = Math.max(...jobs.map(j => j.latestTimestampMs));
|
||||
}
|
||||
|
||||
// if either of the dates are empty, set them to undefined
|
||||
// moment will convert undefined to now.
|
||||
from = (from === '') ? undefined : from;
|
||||
to = (to === '') ? undefined : to;
|
||||
const fromString = moment(from).format(TIME_FORMAT);
|
||||
const toString = moment(to).format(TIME_FORMAT);
|
||||
|
||||
const jobIds = jobs.map(j => j.id);
|
||||
const url = mlJobService.createResultsUrl(jobIds, from, to, location);
|
||||
const url = mlJobService.createResultsUrl(jobIds, fromString, toString, location);
|
||||
return `${chrome.getBasePath()}/app/${url}`;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import React, {
|
|||
} from 'react';
|
||||
|
||||
import { sortBy } from 'lodash';
|
||||
import moment from 'moment';
|
||||
|
||||
import { toLocaleString } from '../../../../util/string_utils';
|
||||
import { ResultLinks, actionsMenuContent } from '../job_actions';
|
||||
|
@ -25,6 +26,7 @@ import {
|
|||
|
||||
const PAGE_SIZE = 10;
|
||||
const PAGE_SIZE_OPTIONS = [10, 25, 50];
|
||||
const TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss';
|
||||
|
||||
export class JobsList extends Component {
|
||||
constructor(props) {
|
||||
|
@ -157,11 +159,13 @@ export class JobsList extends Component {
|
|||
}, {
|
||||
name: 'Latest timestamp',
|
||||
truncateText: false,
|
||||
field: 'latestTimeStampUnix',
|
||||
field: 'latestTimeStampSortValue',
|
||||
sortable: true,
|
||||
render: (time, item) => (
|
||||
<span className="euiTableCellContent__text">
|
||||
{ item.latestTimeStamp.string }
|
||||
{
|
||||
(item.latestTimestampMs === undefined) ? '' : moment(item.latestTimestampMs).format(TIME_FORMAT)
|
||||
}
|
||||
</span>
|
||||
)
|
||||
}, {
|
||||
|
|
|
@ -240,7 +240,7 @@ export class JobsListView extends Component {
|
|||
fullJobsList[job.id] = job.fullJob;
|
||||
delete job.fullJob;
|
||||
}
|
||||
job.latestTimeStampUnix = job.latestTimeStamp.unix;
|
||||
job.latestTimeStampSortValue = (job.latestTimeStampMs || 0);
|
||||
return job;
|
||||
});
|
||||
const filteredJobsSummaryList = filterJobs(jobsSummaryList, this.state.filterClauses);
|
||||
|
|
|
@ -196,6 +196,6 @@ StartDatafeedModal.propTypes = {
|
|||
};
|
||||
|
||||
function getLowestLatestTime(jobs) {
|
||||
const times = jobs.map(j => j.latestTimeStamp.unix.valueOf());
|
||||
const times = jobs.map(j => j.latestTimeStampSortValue);
|
||||
return moment(Math.min(...times));
|
||||
}
|
||||
|
|
|
@ -13,8 +13,6 @@ import { fillResultsWithTimeouts, isRequestTimeout } from './error_utils';
|
|||
import moment from 'moment';
|
||||
import { uniq } from 'lodash';
|
||||
|
||||
const TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss';
|
||||
|
||||
export function jobsProvider(callWithRequest) {
|
||||
|
||||
const { forceDeleteDatafeed, getDatafeedIdsByJobId } = datafeedsProvider(callWithRequest);
|
||||
|
@ -99,8 +97,8 @@ export function jobsProvider(callWithRequest) {
|
|||
const jobs = fullJobsList.map((job) => {
|
||||
const hasDatafeed = (typeof job.datafeed_config === 'object' && Object.keys(job.datafeed_config).length);
|
||||
const {
|
||||
earliest: earliestTimeStamp,
|
||||
latest: latestTimeStamp } = earliestAndLatestTimeStamps(job.data_counts);
|
||||
earliest: earliestTimestampMs,
|
||||
latest: latestTimestampMs } = earliestAndLatestTimeStamps(job.data_counts);
|
||||
|
||||
const tempJob = {
|
||||
id: job.job_id,
|
||||
|
@ -112,8 +110,8 @@ export function jobsProvider(callWithRequest) {
|
|||
hasDatafeed,
|
||||
datafeedId: (hasDatafeed && job.datafeed_config.datafeed_id) ? job.datafeed_config.datafeed_id : '',
|
||||
datafeedState: (hasDatafeed && job.datafeed_config.state) ? job.datafeed_config.state : '',
|
||||
latestTimeStamp,
|
||||
earliestTimeStamp,
|
||||
latestTimestampMs,
|
||||
earliestTimestampMs,
|
||||
nodeName: (job.node) ? job.node.name : undefined,
|
||||
};
|
||||
if (jobIds.find(j => (j === tempJob.id))) {
|
||||
|
@ -243,22 +241,16 @@ export function jobsProvider(callWithRequest) {
|
|||
|
||||
function earliestAndLatestTimeStamps(dataCounts) {
|
||||
const obj = {
|
||||
earliest: { string: '', unix: 0 },
|
||||
latest: { string: '', unix: 0 },
|
||||
earliest: undefined,
|
||||
latest: undefined,
|
||||
};
|
||||
|
||||
if (dataCounts.earliest_record_timestamp) {
|
||||
const ts = moment(dataCounts.earliest_record_timestamp);
|
||||
obj.earliest.string = ts.format(TIME_FORMAT);
|
||||
obj.earliest.unix = ts.valueOf();
|
||||
obj.earliest.moment = ts;
|
||||
obj.earliest = moment(dataCounts.earliest_record_timestamp).valueOf();
|
||||
}
|
||||
|
||||
if (dataCounts.latest_record_timestamp) {
|
||||
const ts = moment(dataCounts.latest_record_timestamp);
|
||||
obj.latest.string = ts.format(TIME_FORMAT);
|
||||
obj.latest.unix = ts.valueOf();
|
||||
obj.latest.moment = ts;
|
||||
obj.latest = moment(dataCounts.latest_record_timestamp).valueOf();
|
||||
}
|
||||
|
||||
return obj;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue