Skip to content

Commit

Permalink
Revert "Pass time range to ML links"
Browse files Browse the repository at this point in the history
This reverts commit 9e339c5.
  • Loading branch information
afgomez authored and Alejandro Fernández Gómez committed Aug 18, 2020
1 parent 2d8c52b commit ec9f024
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ import { encode } from 'rison-node';
import { TimeRange } from '../../../../common/http_api/shared/time_range';
import { useLinkProps, LinkDescriptor } from '../../../hooks/use_link_props';

type DatemathRange = TimeRange | { startTime: string; endTime: string };

export const AnalyzeInMlButton: React.FunctionComponent<{
jobId: string;
partition?: string;
timeRange: DatemathRange;
timeRange: TimeRange;
}> = ({ jobId, partition, timeRange }) => {
const linkProps = useLinkProps(
typeof partition === 'string'
Expand Down Expand Up @@ -44,7 +42,7 @@ export const AnalyzeInMlButton: React.FunctionComponent<{

export const getOverallAnomalyExplorerLinkDescriptor = (
jobId: string,
timeRange: DatemathRange
timeRange: TimeRange
): LinkDescriptor => {
const { from, to } = convertTimeRangeToParams(timeRange);

Expand All @@ -67,7 +65,7 @@ export const getOverallAnomalyExplorerLinkDescriptor = (

export const getEntitySpecificSingleMetricViewerLink = (
jobId: string,
timeRange: DatemathRange,
timeRange: TimeRange,
entities: Record<string, string>
): LinkDescriptor => {
const { from, to } = convertTimeRangeToParams(timeRange);
Expand Down Expand Up @@ -96,15 +94,9 @@ export const getEntitySpecificSingleMetricViewerLink = (
};
};

const convertTimeRangeToParams = (timeRange: DatemathRange): { from: string; to: string } => {
const convertTimeRangeToParams = (timeRange: TimeRange): { from: string; to: string } => {
return {
from:
typeof timeRange.startTime === 'number'
? new Date(timeRange.startTime).toISOString()
: timeRange.startTime,
to:
typeof timeRange.endTime === 'number'
? new Date(timeRange.endTime).toISOString()
: timeRange.endTime,
from: new Date(timeRange.startTime).toISOString(),
to: new Date(timeRange.endTime).toISOString(),
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
} from '../../../../containers/logs/log_analysis/modules/log_entry_rate';
import { LogAnalysisModuleListCard } from './module_list_card';
import type { ModuleId } from './setup_flyout_state';
import { useLogAnalysisResultsUrlState } from '../../../../pages/logs/log_entry_rate/use_log_entry_rate_results_url_state';

export const LogAnalysisModuleList: React.FC<{
onViewModuleSetup: (module: ModuleId) => void;
Expand All @@ -32,8 +31,6 @@ export const LogAnalysisModuleList: React.FC<{
jobIds: logEntryCategoriesJobIds,
} = useLogEntryCategoriesModuleContext();

const { timeRange } = useLogAnalysisResultsUrlState();

const viewLogEntryRateSetupFlyout = useCallback(() => {
onViewModuleSetup('logs_ui_analysis');
}, [onViewModuleSetup]);
Expand All @@ -47,7 +44,6 @@ export const LogAnalysisModuleList: React.FC<{
<EuiFlexItem>
<LogAnalysisModuleListCard
jobId={logEntryRateJobIds['log-entry-rate']}
timeRange={timeRange}
hasSetupCapabilities={hasLogAnalysisSetupCapabilities}
moduleDescription={logEntryRateModule.moduleDescription}
moduleName={logEntryRateModule.moduleName}
Expand All @@ -58,7 +54,6 @@ export const LogAnalysisModuleList: React.FC<{
<EuiFlexItem>
<LogAnalysisModuleListCard
jobId={logEntryCategoriesJobIds['log-entry-categories-count']}
timeRange={timeRange}
hasSetupCapabilities={hasLogAnalysisSetupCapabilities}
moduleDescription={logEntryCategoriesModule.moduleDescription}
moduleName={logEntryCategoriesModule.moduleName}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ import { getOverallAnomalyExplorerLinkDescriptor } from '../../log_analysis_resu

export const LogAnalysisModuleListCard: React.FC<{
jobId: string;
timeRange: { startTime: string; endTime: string };
hasSetupCapabilities: boolean;
moduleDescription: string;
moduleName: string;
moduleStatus: SetupStatus;
onViewSetup: () => void;
}> = ({
jobId,
timeRange,
hasSetupCapabilities,
moduleDescription,
moduleName,
Expand All @@ -36,7 +34,12 @@ export const LogAnalysisModuleListCard: React.FC<{
<EuiIcon color="secondary" size="xxl" type="check" />
);

const viewInMlLinkProps = useLinkProps(getOverallAnomalyExplorerLinkDescriptor(jobId, timeRange));
const viewInMlLinkProps = useLinkProps(
getOverallAnomalyExplorerLinkDescriptor(jobId, {
endTime: Date.now(),
startTime: Date.now() - 86400000 * 14,
})
);

const moduleSetupButton =
moduleStatus.type === 'required' ? (
Expand Down

0 comments on commit ec9f024

Please sign in to comment.