Skip to content

Commit

Permalink
removes some generics
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic committed Mar 12, 2020
1 parent dad3a6b commit 022c93f
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class DataLoader {
fields: FieldRequestConfig[],
interval?: string
): Promise<any[]> {
const stats = await ml.getVisualizerFieldStats<any>({
const stats = await ml.getVisualizerFieldStats({
indexPatternTitle: this._indexPatternTitle,
query,
timeFieldName: this._indexPattern.timeFieldName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ export type LineChartData = Record<DetectorIndex, LineChartPoint[]>;

const eq = (newArgs: any[], lastArgs: any[]) => isEqual(newArgs, lastArgs);

const newJobLineChart = memoizeOne<any>(ml.jobs.newJobLineChart, eq);
const newJobPopulationsChart = memoizeOne<any>(ml.jobs.newJobPopulationsChart, eq);
const getEventRateData = memoizeOne<any>(mlResultsService.getEventRateData, eq);
const getCategoryFields = memoizeOne<any>(getCategoryFieldsOrig, eq);
const newJobLineChart = memoizeOne(ml.jobs.newJobLineChart, eq);
const newJobPopulationsChart = memoizeOne(ml.jobs.newJobPopulationsChart, eq);
const getEventRateData = memoizeOne(mlResultsService.getEventRateData, eq);
const getCategoryFields = memoizeOne(getCategoryFieldsOrig, eq);

export class ChartLoader {
private _indexPatternTitle: IndexPatternTitle = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ import { ml } from '../../../services/ml_api_service';
import { useMlContext } from '../../../contexts/ml';
import {
DatafeedResponse,
DataRecognizerConfigResponse,
JobOverride,
JobResponse,
KibanaObject,
KibanaObjectResponse,
Module,
ModuleJob,
} from '../../../../../common/types/modules';
import { mlJobService } from '../../../services/job_service';
Expand Down Expand Up @@ -106,7 +104,7 @@ export const Page: FC<PageProps> = ({ moduleId, existingGroupIds }) => {
*/
const loadModule = async () => {
try {
const response = await ml.getDataRecognizerModule<Module>({ moduleId });
const response = await ml.getDataRecognizerModule({ moduleId });
setJobs(response.jobs);

const kibanaObjectsResult = await checkForSavedObjects(response.kibana as KibanaObjects);
Expand Down Expand Up @@ -165,7 +163,7 @@ export const Page: FC<PageProps> = ({ moduleId, existingGroupIds }) => {
let jobOverridesPayload: JobOverride[] | null = Object.values(jobOverrides);
jobOverridesPayload = jobOverridesPayload.length > 0 ? jobOverridesPayload : null;

const response = await ml.setupDataRecognizerConfig<DataRecognizerConfigResponse>({
const response = await ml.setupDataRecognizerConfig({
moduleId,
prefix: resultJobPrefix,
query: tempQuery,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,7 @@ export const AnomalyDetectionPanel: FC<Props> = ({ jobCreationDisabled }) => {
const latestTimestamp = group.latest_timestamp;
const startMoment = moment(latestTimestamp);
const twentyFourHoursAgo = startMoment.subtract(24, 'hours').valueOf();
return ml.results.getMaxAnomalyScore<any>(
group.jobIds,
twentyFourHoursAgo,
latestTimestamp
);
return ml.results.getMaxAnomalyScore(group.jobIds, twentyFourHoursAgo, latestTimestamp);
});

const results = await Promise.all(promises);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
} from '../../../../common/types/anomaly_detection_jobs';
import { ES_AGGREGATION } from '../../../../common/constants/aggregation_types';
import { FieldRequestConfig } from '../../datavisualizer/index_based/common';
import { DataRecognizerConfigResponse, Module } from '../../../../common/types/modules';

export interface MlInfoResponse {
defaults: MlServerDefaults;
Expand Down Expand Up @@ -339,8 +340,8 @@ export const ml = {
});
},

getDataRecognizerModule<T>({ moduleId }: { moduleId: string }): Promise<T> {
return http<T>({
getDataRecognizerModule({ moduleId }: { moduleId: string }) {
return http<Module>({
path: `${basePath()}/modules/get_module/${moduleId}`,
method: 'GET',
});
Expand All @@ -353,7 +354,7 @@ export const ml = {
});
},

setupDataRecognizerConfig<T>({
setupDataRecognizerConfig({
moduleId,
prefix,
groups,
Expand All @@ -375,7 +376,7 @@ export const ml = {
start?: number;
end?: number;
jobOverrides?: Array<Partial<Job>>;
}): Promise<T> {
}) {
const body = JSON.stringify({
prefix,
groups,
Expand All @@ -388,14 +389,14 @@ export const ml = {
jobOverrides,
});

return http<T>({
return http<DataRecognizerConfigResponse>({
path: `${basePath()}/modules/setup/${moduleId}`,
method: 'POST',
body,
});
},

getVisualizerFieldStats<T>({
getVisualizerFieldStats({
indexPatternTitle,
query,
timeFieldName,
Expand All @@ -415,7 +416,7 @@ export const ml = {
interval?: string;
fields?: FieldRequestConfig[];
maxExamples?: number;
}): Promise<T> {
}) {
const body = JSON.stringify({
query,
timeFieldName,
Expand All @@ -427,7 +428,7 @@ export const ml = {
maxExamples,
});

return http<T>({
return http<any>({
path: `${basePath()}/data_visualizer/get_field_stats/${indexPatternTitle}`,
method: 'POST',
body,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export const jobs = {
});
},

newJobLineChart<T>(
newJobLineChart(
indexPatternTitle: string,
timeField: string,
start: number,
Expand All @@ -150,7 +150,7 @@ export const jobs = {
aggFieldNamePairs: AggFieldNamePair[],
splitFieldName: string | null,
splitFieldValue: string | null
): Promise<T> {
) {
const body = JSON.stringify({
indexPatternTitle,
timeField,
Expand All @@ -162,14 +162,14 @@ export const jobs = {
splitFieldName,
splitFieldValue,
});
return http<T>({
return http<any>({
path: `${basePath()}/jobs/new_job_line_chart`,
method: 'POST',
body,
});
},

newJobPopulationsChart<T>(
newJobPopulationsChart(
indexPatternTitle: string,
timeField: string,
start: number,
Expand All @@ -178,7 +178,7 @@ export const jobs = {
query: any,
aggFieldNamePairs: AggFieldNamePair[],
splitFieldName: string
): Promise<T> {
) {
const body = JSON.stringify({
indexPatternTitle,
timeField,
Expand All @@ -189,7 +189,7 @@ export const jobs = {
aggFieldNamePairs,
splitFieldName,
});
return http<T>({
return http<any>({
path: `${basePath()}/jobs/new_job_population_chart`,
method: 'POST',
body,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ export const results = {
});
},

getMaxAnomalyScore<T>(jobIds: string[], earliestMs: number, latestMs: number): Promise<T> {
getMaxAnomalyScore(jobIds: string[], earliestMs: number, latestMs: number) {
const body = JSON.stringify({
jobIds,
earliestMs,
latestMs,
});
return http<T>({
return http<any>({
path: `${basePath()}/results/max_anomaly_score`,
method: 'POST',
body,
Expand Down

0 comments on commit 022c93f

Please sign in to comment.