Skip to content

Commit

Permalink
fix imports
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed Aug 30, 2023
1 parent 9664cac commit 37f24df
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* 2.0.
*/

import { computeChi2PValue } from './data_comparison_utils';
import { Histogram } from './types';
import { computeChi2PValue } from './compute_chi_2_pvalue';
import type { Histogram } from './types';

describe('computeChi2PValue()', () => {
test('should return close to 1 if datasets are both empty or nearly identical', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,7 @@ import { estypes } from '@elastic/elasticsearch';

import { createRandomSamplerWrapper } from '@kbn/ml-random-sampler-utils';

export interface Category {
key: string;
count: number;
examples: string[];
sparkline?: Array<{ doc_count: number; key: number; key_as_string: string }>;
}

export interface CategoriesAgg {
categories: {
buckets: Array<{
key: string;
doc_count: number;
hit: { hits: { hits: Array<{ _source: { message: string } }> } };
sparkline: {
buckets: Array<{ key_as_string: string; key: number; doc_count: number }>;
};
}>;
};
}

interface CategoriesSampleAgg {
sample: CategoriesAgg;
}

export interface CatResponse {
rawResponse: estypes.SearchResponseBody<unknown, CategoriesAgg | CategoriesSampleAgg>;
}

export type SparkLinesPerCategory = Record<string, Record<number, number>>;
import type { Category, CategoriesAgg, CatResponse, SparkLinesPerCategory } from './types';

export function processCategoryResults(
result: CatResponse,
Expand Down
38 changes: 38 additions & 0 deletions x-pack/plugins/aiops/common/api/log_categorization/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { estypes } from '@elastic/elasticsearch';

export interface Category {
key: string;
count: number;
examples: string[];
sparkline?: Array<{ doc_count: number; key: number; key_as_string: string }>;
}

export interface CategoriesAgg {
categories: {
buckets: Array<{
key: string;
doc_count: number;
hit: { hits: { hits: Array<{ _source: { message: string } }> } };
sparkline: {
buckets: Array<{ key_as_string: string; key: number; doc_count: number }>;
};
}>;
};
}

interface CategoriesSampleAgg {
sample: CategoriesAgg;
}

export interface CatResponse {
rawResponse: estypes.SearchResponseBody<unknown, CategoriesAgg | CategoriesSampleAgg>;
}

export type SparkLinesPerCategory = Record<string, Record<number, number>>;
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
*/

import React, { FC, useMemo, useState } from 'react';
import { i18n } from '@kbn/i18n';
import type { TimefilterContract } from '@kbn/data-plugin/public';

import {
useEuiBackgroundColor,
EuiInMemoryTable,
Expand All @@ -19,14 +18,25 @@ import {
EuiSpacer,
} from '@elastic/eui';

import { i18n } from '@kbn/i18n';
import type { TimefilterContract } from '@kbn/data-plugin/public';
import { DataViewField } from '@kbn/data-views-plugin/common';
import { Filter } from '@kbn/es-query';
import { useTableState } from '@kbn/ml-in-memory-table';
import { useDiscoverLinks, createFilter, QueryMode, QUERY_MODE } from '../use_discover_links';
import { MiniHistogram } from '../../mini_histogram';

import type {
Category,
SparkLinesPerCategory,
} from '../../../../common/api/log_categorization/types';

import { useEuiTheme } from '../../../hooks/use_eui_theme';
import type { LogCategorizationAppState } from '../../../application/utils/url_state';
import type { EventRate, Category, SparkLinesPerCategory } from '../use_categorize_request';

import { MiniHistogram } from '../../mini_histogram';

import { useDiscoverLinks, createFilter, QueryMode, QUERY_MODE } from '../use_discover_links';
import type { EventRate } from '../use_categorize_request';

import { getLabels } from './labels';
import { TableHeader } from './table_header';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ import React, { FC, useMemo } from 'react';

import { i18n } from '@kbn/i18n';
import { DocumentCountChart as DocumentCountChartRoot } from '@kbn/aiops-components';

import type { Category, SparkLinesPerCategory } from '../../../common/api/log_categorization/types';

import { useAiopsAppContext } from '../../hooks/use_aiops_app_context';
import { DocumentCountStats } from '../../get_document_stats';

import { TotalCountHeader } from '../document_count_content/total_count_header';
import type { Category, SparkLinesPerCategory } from './use_categorize_request';

import type { EventRate } from './use_categorize_request';
import { DocumentCountStats } from '../../get_document_stats';

interface Props {
totalCount: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
* 2.0.
*/
import React, { FC, useState, useEffect, useCallback, useRef, useMemo } from 'react';
import type { SavedSearch } from '@kbn/saved-search-plugin/public';
import type { DataView, DataViewField } from '@kbn/data-views-plugin/public';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';

import {
EuiTitle,
EuiFlyoutHeader,
Expand All @@ -18,26 +15,33 @@ import {
useEuiTheme,
} from '@elastic/eui';

import type { SavedSearch } from '@kbn/saved-search-plugin/public';
import type { DataView, DataViewField } from '@kbn/data-views-plugin/public';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import { buildEmptyFilter, Filter } from '@kbn/es-query';

import { usePageUrlState } from '@kbn/ml-url-state';
import type { FieldValidationResults } from '@kbn/ml-category-validator';

import type { Category, SparkLinesPerCategory } from '../../../common/api/log_categorization/types';

import {
type LogCategorizationPageUrlState,
getDefaultLogCategorizationAppState,
} from '../../application/utils/url_state';
import { createMergedEsQuery } from '../../application/utils/search_utils';
import { useData } from '../../hooks/use_data';
import { useSearch } from '../../hooks/use_search';
import { useAiopsAppContext } from '../../hooks/use_aiops_app_context';

import { useCategorizeRequest } from './use_categorize_request';
import type { EventRate, Category, SparkLinesPerCategory } from './use_categorize_request';
import type { EventRate } from './use_categorize_request';
import { CategoryTable } from './category_table';
import { useAiopsAppContext } from '../../hooks/use_aiops_app_context';
import { InformationText } from './information_text';
import { createMergedEsQuery } from '../../application/utils/search_utils';
import { SamplingMenu } from './sampling_menu';
import { TechnicalPreviewBadge } from './technical_preview_badge';
import { LoadingCategorization } from './loading_categorization';
import { useValidateFieldRequest } from './use_validate_category_field';
import {
type LogCategorizationPageUrlState,
getDefaultLogCategorizationAppState,
} from '../../application/utils/url_state';
import { FieldValidationCallout } from './category_validation_callout';

export interface LogCategorizationPageProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import { isCompleteResponse } from '@kbn/data-plugin/public';
import { useStorage } from '@kbn/ml-local-storage';

import { createCategoryRequest } from '../../../common/api/log_categorization/create_category_request';
import {
processCategoryResults,
type Category,
type CatResponse,
type SparkLinesPerCategory,
} from '../../../common/api/log_categorization/process_category_results';
import { processCategoryResults } from '../../../common/api/log_categorization/process_category_results';
import type {
Category,
CatResponse,
SparkLinesPerCategory,
} from '../../../common/api/log_categorization/types';

import { useAiopsAppContext } from '../../hooks/use_aiops_app_context';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
* 2.0.
*/

import rison from '@kbn/rison';
import moment from 'moment';

import rison from '@kbn/rison';
import type { TimeRangeBounds } from '@kbn/data-plugin/common';
import { i18n } from '@kbn/i18n';
import type { Filter } from '@kbn/es-query';

import type { Category } from '../../../common/api/log_categorization/types';

import type { AiOpsIndexBasedAppState } from '../../application/utils/url_state';
import { useAiopsAppContext } from '../../hooks/use_aiops_app_context';
import type { Category } from './use_categorize_request';

export const QUERY_MODE = {
INCLUDE: 'should',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
import { useRef, useCallback } from 'react';

import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';

import type { FieldValidationResults } from '@kbn/ml-category-validator';

import { AIOPS_API_ENDPOINT } from '../../../common/api';
import { createCategorizeQuery } from '../../../common/api/log_categorization/create_categorize_query';

import { useAiopsAppContext } from '../../hooks/use_aiops_app_context';
import { createCategorizeQuery } from './use_categorize_request';

export function useValidateFieldRequest() {
const { http } = useAiopsAppContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import type {
Category,
CategoriesAgg,
SparkLinesPerCategory,
} from '../../../common/api/log_categorization/process_category_results';
} from '../../../common/api/log_categorization/types';

import { isRequestAbortedError } from '../../lib/is_request_aborted_error';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@
* 2.0.
*/

import React from 'react';

import { SeriesColorAccessor } from '@elastic/charts/dist/chart_types/xy_chart/utils/specs';
import { BarSeries, Chart, ScaleType, Settings } from '@elastic/charts';
import React from 'react';
import { NoChartsData } from './no_charts_data';

import type { Histogram } from '@kbn/ml-chi2test';

import { DATA_COMPARISON_TYPE } from '../constants';
import { DataComparisonField, Histogram } from '../types';
import type { DataComparisonField } from '../types';

import { NoChartsData } from './no_charts_data';

export const SingleDistributionChart = ({
data,
Expand Down

0 comments on commit 37f24df

Please sign in to comment.