perf(core): Optimize executions filtering by metadata (#9477)

This commit is contained in:
Iván Ovejero
2024-05-22 17:20:01 +02:00
committed by GitHub
parent 09a5867707
commit 9bdc83a399
3 changed files with 53 additions and 7 deletions

View File

@@ -257,6 +257,32 @@ describe('ExecutionService', () => {
]);
});
test('should filter executions by `metadata`', async () => {
const workflow = await createWorkflow();
const metadata = [{ key: 'myKey', value: 'myValue' }];
await Promise.all([
createExecution({ status: 'success', metadata }, workflow),
createExecution({ status: 'error' }, workflow),
]);
const query: ExecutionSummaries.RangeQuery = {
kind: 'range',
range: { limit: 20 },
accessibleWorkflowIds: [workflow.id],
metadata,
};
const output = await executionService.findRangeWithCount(query);
expect(output).toEqual({
count: 1,
estimated: false,
results: [expect.objectContaining({ status: 'success' })],
});
});
test('should exclude executions by inaccessible `workflowId`', async () => {
const accessibleWorkflow = await createWorkflow();
const inaccessibleWorkflow = await createWorkflow();