Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Combine getRollup with getExplain API in backend and other code fix (#…
Browse files Browse the repository at this point in the history
…141)

Combine API and other code fix
  • Loading branch information
annie3431 authored Dec 1, 2020
1 parent 644cc3d commit 1bb198a
Show file tree
Hide file tree
Showing 26 changed files with 435 additions and 578 deletions.
80 changes: 30 additions & 50 deletions models/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

// TODO: Backend has PR out to change this model, this needs to be updated once that goes through

import { RollupDimensionItem, RollupMetricItem } from "../public/pages/CreateRollup/models/interfaces";

export interface ManagedIndexMetaData {
index: string;
indexUuid: string;
Expand Down Expand Up @@ -60,38 +58,13 @@ export interface DocumentPolicy {
policy: Policy;
}

//Data model that contains both rollup item and metadata of rollup job
export interface DocumentRollup {
id: string;
seqNo: number;
primaryTerm: number;
rollup: {
rollup_id: string;
enabled: boolean;
schedule: {
interval?: {
start_time?: number;
period: number;
unit: string;
};
cron?: {
expression: string;
timezone: string;
};
};
last_updated_time: number;
enabled_time: number | null;
description: string;
schema_version: number;
source_index: string;
target_index: string;
metadata_id: number | null;
roles: string[];
page_size: number;
delay: number | null;
continuous: boolean;
dimensions: RollupDimensionItem[];
metrics: RollupMetricItem[];
};
_id: string;
_seqNo: number;
_primaryTerm: number;
rollup: Rollup;
metadata: any;
}

// TODO: Fill out when needed
Expand All @@ -112,17 +85,18 @@ export interface Rollup {
continuous: boolean;
delay: number | null;
description: string;
dimensions: (DateHistogramItem | TermsItem | HistogramItem)[];
dimensions: RollupDimensionItem[];
enabled: boolean;
enabledTime: number | null;
lastUpdatedTime: number;
metadata_id: number | null;
last_updated_time: number;
metadata_id: string | null;
metrics: MetricItem[];
page_size: number;
schedule: IntervalSchedule | CronSchedule;
schemaVersion: number;
schema_version: number;
source_index: string;
target_index: string;
roles: string[];
}

export interface RollupMetadata {
Expand All @@ -132,11 +106,11 @@ export interface RollupMetadata {
seq_no: number;
primary_term: number;
rollup_id: string;
after_key: Map<String, any> | null;
after_key: Map<string, any> | null;
last_updated_time: number;
continuous: {
next_window_start_time: number;
next_window_end_time: number;
next_window_start_time: number | null;
next_window_end_time: number | null;
} | null;
status: string;
failure_reason: string | null;
Expand All @@ -151,14 +125,18 @@ export interface RollupMetadata {
}

export interface IntervalSchedule {
startTime: number | null;
period: number;
unit: string;
interval: {
startTime: number | null;
period: number;
unit: string;
};
}

export interface CronSchedule {
expression: string;
timezone: string;
cron: {
expression: string;
timezone: string;
};
}

//Frontend dimension data model
Expand All @@ -182,14 +160,16 @@ export interface MetricItem {

export interface FieldItem {
label: string;
type?: string;
type: string | undefined;
}

interface DateHistogramItem {
sourceField: string;
fixed_interval: string | null;
calendar_interval: string | null;
timezone: string;
date_histogram: {
sourceField: string;
fixed_interval: string | null;
calendar_interval: string | null;
timezone: string;
};
}

interface TermsItem {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ import {
} from "@elastic/eui";
import { ContentPanel, ContentPanelActions } from "../../../../components/ContentPanel";
import { ModalConsumer } from "../../../../components/Modal";
import { DimensionItem, MetricItem } from "../../models/interfaces";
import { DEFAULT_PAGE_SIZE_OPTIONS } from "../../../Rollups/utils/constants";
import { parseTimeunit } from "../../utils/helpers";
import { DimensionItem, MetricItem } from "../../../../../models/interfaces";

interface HistogramAndMetricsProps {
rollupId: string;
Expand Down Expand Up @@ -79,7 +79,7 @@ const aggregationColumns: EuiTableFieldDataColumnType<DimensionItem>[] = [
field: "field.type",
name: "Field type",
align: "left",
render: (type) => (type == null ? "-" : type),
render: (type) => (type == undefined ? "-" : type),
},
{
field: "aggregationMethod",
Expand All @@ -98,7 +98,7 @@ const aggregationColumns: EuiTableFieldDataColumnType<DimensionItem>[] = [
},
];

const metricsColumns = [
const metricsColumns: EuiTableFieldDataColumnType<MetricItem>[] = [
{
field: "source_field.label",
name: "Field Name",
Expand Down
32 changes: 16 additions & 16 deletions public/pages/CreateRollup/components/Schedule/Schedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ import {
EuiFormHelpText,
EuiText,
} from "@elastic/eui";
import { CalendarTimeunitOptions, DelayTimeunitOptions, ScheduleIntervalTimeunitOptions } from "../../utils/constants";
import { DelayTimeunitOptions, ScheduleIntervalTimeunitOptions } from "../../utils/constants";
import { ContentPanel } from "../../../../components/ContentPanel";

interface ScheduleProps {
isEdit: boolean;
rollupId: string;
rollupIdError: string;
jobEnabledByDefault: boolean;
recurringJob: string;
recurringDefinition: string;
continuousJob: string;
continuousDefinition: string;
interval: number;
intervalTimeunit: string;
intervalError: string;
Expand All @@ -52,8 +52,8 @@ interface ScheduleProps {
onChangeDelayTime: (e: ChangeEvent<HTMLInputElement>) => void;
onChangeIntervalTime: (e: ChangeEvent<HTMLInputElement>) => void;
onChangePage: (e: ChangeEvent<HTMLInputElement>) => void;
onChangeRecurringDefinition: (e: ChangeEvent<HTMLSelectElement>) => void;
onChangeRecurringJob: (optionId: string) => void;
onChangeContinuousDefinition: (e: ChangeEvent<HTMLSelectElement>) => void;
onChangeContinuousJob: (optionId: string) => void;
onChangeDelayTimeunit: (e: ChangeEvent<HTMLSelectElement>) => void;
onChangeIntervalTimeunit: (e: ChangeEvent<HTMLSelectElement>) => void;
}
Expand Down Expand Up @@ -98,10 +98,10 @@ const selectInterval = (
</React.Fragment>
);

const isRecurring = (recurringJob: string, onChangeRecurringJob: (optionId: string) => void) => (
const isContinuous = (continuousJob: string, onChangeContinuousJob: (optionId: string) => void) => (
<React.Fragment>
<EuiFormRow label="Continuous">
<EuiRadioGroup options={radios} idSelected={recurringJob} onChange={(id) => onChangeRecurringJob(id)} name="recurringJob" />
<EuiRadioGroup options={radios} idSelected={continuousJob} onChange={(id) => onChangeContinuousJob(id)} name="continuousJob" />
</EuiFormRow>
<EuiSpacer size="m" />
</React.Fragment>
Expand All @@ -118,8 +118,8 @@ export default class Schedule extends Component<ScheduleProps> {
const {
isEdit,
jobEnabledByDefault,
recurringJob,
recurringDefinition,
continuousJob,
continuousDefinition,
interval,
intervalTimeunit,
intervalError,
Expand All @@ -134,8 +134,8 @@ export default class Schedule extends Component<ScheduleProps> {
onChangeDelayTime,
onChangeIntervalTime,
onChangePage,
onChangeRecurringDefinition,
onChangeRecurringJob,
onChangeContinuousDefinition,
onChangeContinuousJob,
onChangeDelayTimeunit,
onChangeIntervalTimeunit,
} = this.props;
Expand All @@ -152,22 +152,22 @@ export default class Schedule extends Component<ScheduleProps> {
/>
)}
<EuiSpacer size="m" />
{!isEdit && isRecurring(recurringJob, onChangeRecurringJob)}
{!isEdit && isContinuous(continuousJob, onChangeContinuousJob)}

<EuiFormRow label="Rollup execution frequency">
<EuiSelect
id="recurringDefinition"
id="continuousDefinition"
options={[
{ value: "fixed", text: "Define by fixed interval" },
{ value: "cron", text: "Define by cron expression" },
]}
value={recurringDefinition}
onChange={onChangeRecurringDefinition}
value={continuousDefinition}
onChange={onChangeContinuousDefinition}
/>
</EuiFormRow>
<EuiSpacer size="m" />

{recurringDefinition == "fixed" ? (
{continuousDefinition == "fixed" ? (
selectInterval(interval, intervalTimeunit, intervalError, onChangeIntervalTime, onChangeIntervalTimeunit)
) : (
<React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ interface ScheduleRolesAndNotificationsProps {
rollupId: string;
onChangeStep: (step: number) => void;
jobEnabledByDefault: boolean;
recurringJob: string;
recurringDefinition: string;
continuousJob: string;
continuousDefinition: string;
interval: number;
intervalTimeunit: string;
cronExpression: string;
Expand All @@ -39,8 +39,8 @@ export default class ScheduleRolesAndNotifications extends Component<ScheduleRol
const {
onChangeStep,
jobEnabledByDefault,
recurringJob,
recurringDefinition,
continuousJob,
continuousDefinition,
interval,
intervalTimeunit,
cronExpression,
Expand All @@ -49,8 +49,8 @@ export default class ScheduleRolesAndNotifications extends Component<ScheduleRol
delayTimeunit,
} = this.props;

let scheduleText = recurringJob ? "Continuous, " : "Not continuous, ";
if (recurringDefinition == "fixed") {
let scheduleText = continuousJob ? "Continuous, " : "Not continuous, ";
if (continuousDefinition == "fixed") {
scheduleText += "every " + interval + " " + parseTimeunit(intervalTimeunit);
} else {
scheduleText += "defined by cron expression: " + cronExpression;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ import React from "react";
import { fireEvent, render, wait } from "@testing-library/react";
import { Redirect, Route, RouteComponentProps, Switch } from "react-router-dom";
import { MemoryRouter as Router } from "react-router";
import { toastNotifications } from "ui/notify";
import chrome from "ui/chrome";
import userEvent from "@testing-library/user-event";
import { ServicesConsumer, ServicesContext } from "../../../../services";
import { browserServicesMock } from "../../../../../test/mocks";
import { BrowserServices } from "../../../../models/interfaces";
import { ModalProvider, ModalRoot } from "../../../../components/Modal";
import { BREADCRUMBS, ROUTES } from "../../../../utils/constants";
import CreateRollupForm from "./CreateRollupForm";
import chrome from "ui/chrome";
import userEvent from "@testing-library/user-event";
import { toastNotifications } from "ui/notify";
import { testRollup } from "../../utils/constants";

const indices = [
{
Expand Down
Loading

0 comments on commit 1bb198a

Please sign in to comment.