Skip to content

Commit

Permalink
migrate saved object, reset validation counter and fix typo attribute (
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 authored Apr 7, 2020
1 parent cfae46b commit 3dc4515
Show file tree
Hide file tree
Showing 5 changed files with 390 additions and 243 deletions.
14 changes: 0 additions & 14 deletions src/legacy/core_plugins/vis_type_timeseries/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,6 @@ const metricsPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPlu
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
hacks: [resolve(__dirname, 'public/legacy')],
injectDefaultVars: server => ({}),
mappings: {
'tsvb-validation-telemetry': {
properties: {
failedRequests: {
type: 'long',
},
},
},
},
savedObjectSchemas: {
'tsvb-validation-telemetry': {
isNamespaceAgnostic: true,
},
},
},
config(Joi: any) {
return Joi.object({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { flow } from 'lodash';
import { SavedObjectMigrationFn, SavedObjectsType } from 'kibana/server';

const resetCount: SavedObjectMigrationFn = doc => ({
...doc,
attributes: {
...doc.attributes,
failedRequests: 0,
},
});

export const tsvbTelemetrySavedObjectType: SavedObjectsType = {
name: 'tsvb-validation-telemetry',
hidden: false,
namespaceAgnostic: true,
mappings: {
properties: {
failedRequests: {
type: 'long',
},
},
},
migrations: {
'7.7.0': flow<SavedObjectMigrationFn>(resetCount),
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import { APICaller, CoreSetup, Plugin, PluginInitializerContext } from 'kibana/server';
import { UsageCollectionSetup } from '../../../usage_collection/server';
import { tsvbTelemetrySavedObjectType } from './saved_object_type';

export interface ValidationTelemetryServiceSetup {
logFailedValidation: () => void;
Expand All @@ -36,6 +37,7 @@ export class ValidationTelemetryService implements Plugin<ValidationTelemetrySer
globalConfig$: PluginInitializerContext['config']['legacy']['globalConfig$'];
}
) {
core.savedObjects.registerType(tsvbTelemetrySavedObjectType);
globalConfig$.subscribe(config => {
this.kibanaIndex = config.kibana.index;
});
Expand Down
Loading

0 comments on commit 3dc4515

Please sign in to comment.