fix: Add accurate concurrent executions count to executions list (#19249)

This commit is contained in:
Irénée
2025-09-15 13:23:05 +01:00
committed by GitHub
parent 7ded694ce7
commit dc75be3a6f
11 changed files with 225 additions and 62 deletions

View File

@@ -291,4 +291,18 @@ describe('ExecutionRepository', () => {
);
});
});
describe('getConcurrentExecutionsCount', () => {
test('should count running executions with mode webhook or trigger', async () => {
const mockCount = 5;
entityManager.count.mockResolvedValueOnce(mockCount);
const result = await executionRepository.getConcurrentExecutionsCount();
expect(entityManager.count).toHaveBeenCalledWith(ExecutionEntity, {
where: { status: 'running', mode: In(['webhook', 'trigger']) },
});
expect(result).toBe(mockCount);
});
});
});

View File

@@ -1137,4 +1137,16 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
return executions.map(({ id }) => id);
}
/**
* The number of executions that are running and count towards the concurrent executions limit.
* Concurrency control only applies to executions started from a webhook or trigger node.
*/
async getConcurrentExecutionsCount() {
const concurrentExecutionsCount = await this.count({
where: { status: 'running', mode: In(['webhook', 'trigger']) },
});
return concurrentExecutionsCount;
}
}