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

@@ -495,6 +495,7 @@ export interface IExecutionsListResponse {
count: number;
results: ExecutionSummaryWithScopes[];
estimated: boolean;
concurrentExecutionsCount: number;
}
export interface IExecutionsCurrentSummaryExtended {

View File

@@ -27,10 +27,12 @@ const props = withDefaults(
executions: ExecutionSummaryWithScopes[];
filters: ExecutionFilterType;
total?: number;
concurrentTotal?: number;
estimated?: boolean;
}>(),
{
total: 0,
concurrentTotal: 0,
estimated: false,
},
);
@@ -76,16 +78,11 @@ const isAnnotationEnabled = computed(
() => settingsStore.isEnterpriseFeatureEnabled[EnterpriseEditionFeature.AdvancedExecutionFilters],
);
/**
* Calculate the number of executions counted towards the production executions concurrency limit.
* Evaluation executions are not counted towards this limit and the evaluation limit isn't shown in the UI.
*/
const runningExecutionsCount = computed(() => {
return props.executions.filter(
(execution) =>
execution.status === 'running' && ['webhook', 'trigger'].includes(execution.mode),
).length;
});
// In 'queue' mode concurrency control is applied per worker and returning a global count
// of concurrent executions would not be meaningful/helpful.
const showConcurrencyHeader = computed(
() => settingsStore.isConcurrencyEnabled && !settingsStore.isQueueModeEnabled,
);
watch(
() => props.executions,
@@ -338,8 +335,8 @@ const goToUpgrade = () => {
<div style="margin-left: auto">
<ConcurrentExecutionsHeader
v-if="settingsStore.isConcurrencyEnabled"
:running-executions-count="runningExecutionsCount"
v-if="showConcurrencyHeader"
:running-executions-count="concurrentTotal"
:concurrency-cap="settingsStore.concurrency"
:is-cloud-deployment="settingsStore.isCloudDeployment"
@go-to-upgrade="goToUpgrade"

View File

@@ -54,16 +54,11 @@ const executionListRef = ref<HTMLElement | null>(null);
const workflowPermissions = computed(() => getResourcePermissions(props.workflow?.scopes).workflow);
/**
* Calculate the number of executions counted towards the production executions concurrency limit.
* Evaluation executions are not counted towards this limit and the evaluation limit isn't shown in the UI.
*/
const runningExecutionsCount = computed(() => {
return props.executions.filter(
(execution) =>
execution.status === 'running' && ['webhook', 'trigger'].includes(execution.mode),
).length;
});
// In 'queue' mode concurrency control is applied per worker and returning a global count
// of concurrent executions would not be meaningful/helpful.
const showConcurrencyHeader = computed(
() => settingsStore.isConcurrencyEnabled && !settingsStore.isQueueModeEnabled,
);
watch(
() => route,
@@ -196,8 +191,8 @@ const goToUpgrade = () => {
</n8n-heading>
<ConcurrentExecutionsHeader
v-if="settingsStore.isConcurrencyEnabled"
:running-executions-count="runningExecutionsCount"
v-if="showConcurrencyHeader"
:running-executions-count="executionsStore.concurrentExecutionsCount"
:concurrency-cap="settingsStore.concurrency"
:is-cloud-deployment="settingsStore.isCloudDeployment"
@go-to-upgrade="goToUpgrade"

View File

@@ -52,6 +52,7 @@ export const useExecutionsStore = defineStore('executions', () => {
const executionsById = ref<Record<string, ExecutionSummaryWithScopes>>({});
const executionsCount = ref(0);
const executionsCountEstimated = ref(false);
const concurrentExecutionsCount = ref(0);
const executions = computed(() => {
const data = Object.values(executionsById.value);
@@ -176,6 +177,7 @@ export const useExecutionsStore = defineStore('executions', () => {
executionsCount.value = data.count;
executionsCountEstimated.value = data.estimated;
concurrentExecutionsCount.value = data.concurrentExecutionsCount;
return data;
} finally {
loading.value = false;
@@ -285,6 +287,7 @@ export const useExecutionsStore = defineStore('executions', () => {
currentExecutionsById.value = {};
executionsCount.value = 0;
executionsCountEstimated.value = false;
concurrentExecutionsCount.value = 0;
}
function reset() {
@@ -302,6 +305,7 @@ export const useExecutionsStore = defineStore('executions', () => {
executions,
executionsCount,
executionsCountEstimated,
concurrentExecutionsCount,
executionsByWorkflowId,
currentExecutions,
currentExecutionsByWorkflowId,

View File

@@ -27,8 +27,13 @@ const documentTitle = useDocumentTitle();
const toast = useToast();
const overview = useProjectPages();
const { executionsCount, executionsCountEstimated, filters, allExecutions } =
storeToRefs(executionsStore);
const {
executionsCount,
executionsCountEstimated,
concurrentExecutionsCount,
filters,
allExecutions,
} = storeToRefs(executionsStore);
onBeforeMount(async () => {
await loadWorkflows();
@@ -91,6 +96,7 @@ async function onExecutionStop() {
:filters="filters"
:total="executionsCount"
:estimated-total="executionsCountEstimated"
:concurrent-total="concurrentExecutionsCount"
@execution:stop="onExecutionStop"
@update:filters="onUpdateFilters"
>