mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 09:36:44 +00:00
fix: Add accurate concurrent executions count to executions list (#19249)
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user