Skip to content

Commit

Permalink
Re-use updated_at instead of creating createdAt
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecote committed Jan 20, 2020
1 parent f853354 commit f0a0385
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 15 deletions.
3 changes: 0 additions & 3 deletions x-pack/legacy/plugins/actions/mappings.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
},
"apiKey": {
"type": "binary"
},
"createdAt": {
"type": "date"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,14 @@
* you may not use this file except in compliance with the Elastic License.
*/

import sinon from 'sinon';
import { taskManagerMock } from '../../../../plugins/task_manager/server/task_manager.mock';
import { createExecuteFunction } from './create_execute_function';
import { savedObjectsClientMock } from '../../../../../src/core/server/mocks';

let fakeTimer: sinon.SinonFakeTimers;
const mockTaskManager = taskManagerMock.start();
const savedObjectsClient = savedObjectsClientMock.create();
const getBasePath = jest.fn();

beforeAll(() => {
fakeTimer = sinon.useFakeTimers();
});
afterAll(() => fakeTimer.restore());

beforeEach(() => jest.resetAllMocks());

describe('execute()', () => {
Expand Down Expand Up @@ -69,7 +62,6 @@ describe('execute()', () => {
actionId: '123',
params: { baz: false },
apiKey: Buffer.from('123:abc').toString('base64'),
createdAt: '1970-01-01T00:00:00.000Z',
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export function createExecuteFunction({
actionId: id,
params,
apiKey,
createdAt: new Date().toISOString(),
});

await taskManager.schedule({
Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/actions/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export class Plugin {
plugins.encryptedSavedObjects.registerType({
type: 'action_task_params',
attributesToEncrypt: new Set(['apiKey']),
attributesToExcludeFromAAD: new Set(['createdAt']),
});

const actionExecutor = new ActionExecutor();
Expand Down Expand Up @@ -159,6 +158,7 @@ export class Plugin {
actionTypeRegistry: actionTypeRegistry!,
});
taskRunnerFactory!.initialize({
logger,
encryptedSavedObjectsPlugin: plugins.encryptedSavedObjects,
getBasePath,
spaceIdToNamespace,
Expand Down
1 change: 0 additions & 1 deletion x-pack/legacy/plugins/actions/server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,4 @@ export interface ActionTaskParams extends SavedObjectAttributes {
actionId: string;
params: Record<string, any>;
apiKey?: string;
createdAt: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class TaskManagerUtils {
},
{
range: {
'action_task_params.createdAt': {
updated_at: {
gte: createdAtFilter,
},
},
Expand Down

0 comments on commit f0a0385

Please sign in to comment.