Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discover] Remove usage of savedObjects API #138997

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/plugins/data_views/common/data_views/data_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ export class DataView implements DataViewBase {
* Name of the data view. Human readable name used to differentiate data view.
*/
public name: string = '';
/**
* Timestamp of the last time this data view was updated.
*/
public updatedAt: string | undefined;

/**
* constructor
Expand Down Expand Up @@ -181,6 +185,7 @@ export class DataView implements DataViewBase {
this.runtimeFieldMap = cloneDeep(spec.runtimeFieldMap) || {};
this.namespaces = spec.namespaces || [];
this.name = spec.name || '';
this.updatedAt = spec.updatedAt;
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/data_views/common/data_views/data_views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ export class DataViewsService {
*/

savedObjectToSpec = (savedObject: SavedObject<DataViewAttributes>): DataViewSpec => {
// @ts-ignore
const {
id,
version,
Expand All @@ -642,6 +643,8 @@ export class DataViewsService {
allowNoIndex,
name,
},
// @ts-ignore
updatedAt,
} = savedObject;

const parsedSourceFilters = sourceFilters ? JSON.parse(sourceFilters) : undefined;
Expand All @@ -668,6 +671,7 @@ export class DataViewsService {
allowNoIndex,
runtimeFieldMap: parsedRuntimeFieldMap,
name,
updatedAt,
};
};

Expand Down
4 changes: 4 additions & 0 deletions src/plugins/data_views/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,10 @@ export type DataViewSpec = {
* Name of the data view. Human readable name used to differentiate data view.
*/
name?: string;
/**
* Timestamp of the last time this data view was updated.
*/
updatedAt?: string;
};

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,8 @@ export function ViewAlertRoute() {
return;
}

const dataViewSavedObject = await core.savedObjects.client.get('index-pattern', dataView.id!);
const alertUpdatedAt = fetchedAlert.updatedAt;
const dataViewUpdatedAt = dataViewSavedObject.updatedAt!;
const dataViewUpdatedAt = dataView.updatedAt!;
// data view updated after the last update of the alert rule
if (
openActualAlert &&
Expand Down