mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(editor): Fix executions sorting (#11808)
This commit is contained in:
parent
187edf28aa
commit
cd5ad65e90
|
@ -369,6 +369,7 @@ export interface IExecutionBase {
|
||||||
retryOf?: string;
|
retryOf?: string;
|
||||||
retrySuccessId?: string;
|
retrySuccessId?: string;
|
||||||
startedAt: Date;
|
startedAt: Date;
|
||||||
|
createdAt: Date;
|
||||||
stoppedAt?: Date;
|
stoppedAt?: Date;
|
||||||
workflowId?: string; // To be able to filter executions easily //
|
workflowId?: string; // To be able to filter executions easily //
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ const executionDataFactory = (): ExecutionSummary => ({
|
||||||
id: faker.string.uuid(),
|
id: faker.string.uuid(),
|
||||||
finished: faker.datatype.boolean(),
|
finished: faker.datatype.boolean(),
|
||||||
mode: faker.helpers.arrayElement(['manual', 'trigger']),
|
mode: faker.helpers.arrayElement(['manual', 'trigger']),
|
||||||
|
createdAt: faker.date.past(),
|
||||||
startedAt: faker.date.past(),
|
startedAt: faker.date.past(),
|
||||||
stoppedAt: faker.date.past(),
|
stoppedAt: faker.date.past(),
|
||||||
workflowId: faker.number.int().toString(),
|
workflowId: faker.number.int().toString(),
|
||||||
|
|
|
@ -50,6 +50,7 @@ const executionDataFactory = (): ExecutionSummaryWithScopes => ({
|
||||||
id: faker.string.uuid(),
|
id: faker.string.uuid(),
|
||||||
finished: faker.datatype.boolean(),
|
finished: faker.datatype.boolean(),
|
||||||
mode: faker.helpers.arrayElement(['manual', 'trigger']),
|
mode: faker.helpers.arrayElement(['manual', 'trigger']),
|
||||||
|
createdAt: faker.date.past(),
|
||||||
startedAt: faker.date.past(),
|
startedAt: faker.date.past(),
|
||||||
stoppedAt: faker.date.past(),
|
stoppedAt: faker.date.past(),
|
||||||
workflowId: faker.number.int().toString(),
|
workflowId: faker.number.int().toString(),
|
||||||
|
|
|
@ -252,6 +252,7 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
|
||||||
finished: false,
|
finished: false,
|
||||||
mode: 'manual',
|
mode: 'manual',
|
||||||
status: 'running',
|
status: 'running',
|
||||||
|
createdAt: new Date(),
|
||||||
startedAt: new Date(),
|
startedAt: new Date(),
|
||||||
stoppedAt: undefined,
|
stoppedAt: undefined,
|
||||||
workflowId: workflow.id,
|
workflowId: workflow.id,
|
||||||
|
|
|
@ -22,6 +22,7 @@ describe('executions.store', () => {
|
||||||
id: '3',
|
id: '3',
|
||||||
mode: 'manual',
|
mode: 'manual',
|
||||||
status: 'success',
|
status: 'success',
|
||||||
|
createdAt: new Date('2021-01-01T00:00:00Z'),
|
||||||
startedAt: new Date('2021-01-03T00:00:00Z'),
|
startedAt: new Date('2021-01-03T00:00:00Z'),
|
||||||
workflowId: '1',
|
workflowId: '1',
|
||||||
scopes: [],
|
scopes: [],
|
||||||
|
@ -30,6 +31,7 @@ describe('executions.store', () => {
|
||||||
id: '2',
|
id: '2',
|
||||||
mode: 'manual',
|
mode: 'manual',
|
||||||
status: 'success',
|
status: 'success',
|
||||||
|
createdAt: new Date('2021-01-02T00:00:00Z'),
|
||||||
startedAt: new Date('2021-01-02T00:00:00Z'),
|
startedAt: new Date('2021-01-02T00:00:00Z'),
|
||||||
workflowId: '1',
|
workflowId: '1',
|
||||||
scopes: [],
|
scopes: [],
|
||||||
|
@ -38,6 +40,7 @@ describe('executions.store', () => {
|
||||||
id: '1',
|
id: '1',
|
||||||
mode: 'manual',
|
mode: 'manual',
|
||||||
status: 'success',
|
status: 'success',
|
||||||
|
createdAt: new Date('2021-01-03T00:00:00Z'),
|
||||||
startedAt: new Date('2021-01-01T00:00:00Z'),
|
startedAt: new Date('2021-01-01T00:00:00Z'),
|
||||||
workflowId: '1',
|
workflowId: '1',
|
||||||
scopes: [],
|
scopes: [],
|
||||||
|
@ -55,9 +58,13 @@ describe('executions.store', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should delete executions started before given date', async () => {
|
it('should delete executions started before given date', async () => {
|
||||||
await executionsStore.deleteExecutions({ deleteBefore: mockExecutions[1].startedAt });
|
const deleteBefore = mockExecutions[1].startedAt;
|
||||||
|
await executionsStore.deleteExecutions({ deleteBefore });
|
||||||
|
|
||||||
expect(executionsStore.executions).toEqual([mockExecutions[0], mockExecutions[1]]);
|
expect(executionsStore.executions.length).toBe(2);
|
||||||
|
executionsStore.executions.forEach(({ startedAt }) =>
|
||||||
|
expect(startedAt.getTime()).toBeGreaterThanOrEqual(deleteBefore.getTime()),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should delete all executions if given date is now', async () => {
|
it('should delete all executions if given date is now', async () => {
|
||||||
|
@ -66,4 +73,40 @@ describe('executions.store', () => {
|
||||||
expect(executionsStore.executions).toEqual([]);
|
expect(executionsStore.executions).toEqual([]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should sort execution by createdAt', () => {
|
||||||
|
const mockExecutions: ExecutionSummaryWithScopes[] = [
|
||||||
|
{
|
||||||
|
id: '1',
|
||||||
|
mode: 'manual',
|
||||||
|
status: 'success',
|
||||||
|
createdAt: new Date('2021-01-01T00:00:00Z'),
|
||||||
|
startedAt: new Date('2021-02-03T00:00:00Z'),
|
||||||
|
workflowId: '1',
|
||||||
|
scopes: [],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '2',
|
||||||
|
mode: 'manual',
|
||||||
|
status: 'success',
|
||||||
|
createdAt: new Date('2021-01-02T00:00:00Z'),
|
||||||
|
startedAt: new Date('2021-02-02T00:00:00Z'),
|
||||||
|
workflowId: '1',
|
||||||
|
scopes: [],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '3',
|
||||||
|
mode: 'manual',
|
||||||
|
status: 'success',
|
||||||
|
createdAt: new Date('2021-01-03T00:00:00Z'),
|
||||||
|
startedAt: new Date('2021-02-01T00:00:00Z'),
|
||||||
|
workflowId: '1',
|
||||||
|
scopes: [],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
mockExecutions.forEach(executionsStore.addExecution);
|
||||||
|
|
||||||
|
expect(executionsStore.executions.at(-1)).toEqual(expect.objectContaining({ id: '1' }));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -50,7 +50,7 @@ export const useExecutionsStore = defineStore('executions', () => {
|
||||||
const data = Object.values(executionsById.value);
|
const data = Object.values(executionsById.value);
|
||||||
|
|
||||||
data.sort((a, b) => {
|
data.sort((a, b) => {
|
||||||
return new Date(b.startedAt).getTime() - new Date(a.startedAt).getTime();
|
return new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime();
|
||||||
});
|
});
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|
|
@ -656,6 +656,7 @@ function generateMockExecutionEvents() {
|
||||||
finished: false,
|
finished: false,
|
||||||
mode: 'cli',
|
mode: 'cli',
|
||||||
startedAt: new Date(),
|
startedAt: new Date(),
|
||||||
|
createdAt: new Date(),
|
||||||
status: 'new',
|
status: 'new',
|
||||||
data: {
|
data: {
|
||||||
resultData: {
|
resultData: {
|
||||||
|
|
|
@ -2591,7 +2591,7 @@ export interface ExecutionSummary {
|
||||||
retryOf?: string | null;
|
retryOf?: string | null;
|
||||||
retrySuccessId?: string | null;
|
retrySuccessId?: string | null;
|
||||||
waitTill?: Date;
|
waitTill?: Date;
|
||||||
createdAt?: Date;
|
createdAt: Date;
|
||||||
startedAt: Date;
|
startedAt: Date;
|
||||||
stoppedAt?: Date;
|
stoppedAt?: Date;
|
||||||
workflowId: string;
|
workflowId: string;
|
||||||
|
|
Loading…
Reference in a new issue