mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
fix(editor): Execution list micro optimization (#5244)
* fix(editor): Execution list micro optimization * fix(editor): remove old variable usage
This commit is contained in:
parent
c711c53ad6
commit
a1710fbd27
|
@ -554,12 +554,7 @@ export default mixins(externalHooks, genericHelpers, executionHelpers, restApi,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getWorkflowName(workflowId: string): string | undefined {
|
getWorkflowName(workflowId: string): string | undefined {
|
||||||
const workflow = this.workflows.find((data) => data.id === workflowId);
|
return this.workflows.find((data) => data.id === workflowId)?.name;
|
||||||
if (workflow === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
return workflow.name;
|
|
||||||
},
|
},
|
||||||
async loadActiveExecutions(): Promise<void> {
|
async loadActiveExecutions(): Promise<void> {
|
||||||
const activeExecutions = await this.restApi().getCurrentExecutions(
|
const activeExecutions = await this.restApi().getCurrentExecutions(
|
||||||
|
@ -585,7 +580,7 @@ export default mixins(externalHooks, genericHelpers, executionHelpers, restApi,
|
||||||
// iF you use firstId, filtering id >= 504 you won't
|
// iF you use firstId, filtering id >= 504 you won't
|
||||||
// ever get ids 500, 501, 502 and 503 when they finish
|
// ever get ids 500, 501, 502 and 503 when they finish
|
||||||
const pastExecutionsPromise: Promise<IExecutionsListResponse> =
|
const pastExecutionsPromise: Promise<IExecutionsListResponse> =
|
||||||
this.restApi().getPastExecutions(filter, 30);
|
this.restApi().getPastExecutions(filter, this.requestItemsPerRequest);
|
||||||
const currentExecutionsPromise: Promise<IExecutionsCurrentSummaryExtended[]> =
|
const currentExecutionsPromise: Promise<IExecutionsCurrentSummaryExtended[]> =
|
||||||
this.restApi().getCurrentExecutions({});
|
this.restApi().getCurrentExecutions({});
|
||||||
|
|
||||||
|
@ -603,7 +598,8 @@ export default mixins(externalHooks, genericHelpers, executionHelpers, restApi,
|
||||||
this.workflowsStore.activeExecutions = results[1];
|
this.workflowsStore.activeExecutions = results[1];
|
||||||
|
|
||||||
// execution IDs are typed as string, int conversion is necessary so we can order.
|
// execution IDs are typed as string, int conversion is necessary so we can order.
|
||||||
const alreadyPresentExecutionIds = this.finishedExecutions.map((exec) =>
|
const alreadyPresentExecutions = [...this.finishedExecutions];
|
||||||
|
const alreadyPresentExecutionIds = alreadyPresentExecutions.map((exec) =>
|
||||||
parseInt(exec.id, 10),
|
parseInt(exec.id, 10),
|
||||||
);
|
);
|
||||||
let lastId = 0;
|
let lastId = 0;
|
||||||
|
@ -611,7 +607,7 @@ export default mixins(externalHooks, genericHelpers, executionHelpers, restApi,
|
||||||
for (let i = results[0].results.length - 1; i >= 0; i--) {
|
for (let i = results[0].results.length - 1; i >= 0; i--) {
|
||||||
const currentItem = results[0].results[i];
|
const currentItem = results[0].results[i];
|
||||||
const currentId = parseInt(currentItem.id, 10);
|
const currentId = parseInt(currentItem.id, 10);
|
||||||
if (lastId !== 0 && isNaN(currentId) === false) {
|
if (lastId !== 0 && !isNaN(currentId)) {
|
||||||
// We are doing this iteration to detect possible gaps.
|
// We are doing this iteration to detect possible gaps.
|
||||||
// The gaps are used to remove executions that finished
|
// The gaps are used to remove executions that finished
|
||||||
// and were deleted from database but were displaying
|
// and were deleted from database but were displaying
|
||||||
|
@ -631,14 +627,14 @@ export default mixins(externalHooks, genericHelpers, executionHelpers, restApi,
|
||||||
// Execution that we received is already present.
|
// Execution that we received is already present.
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.finishedExecutions[executionIndex].finished === false &&
|
alreadyPresentExecutions[executionIndex].finished === false &&
|
||||||
currentItem.finished === true
|
currentItem.finished === true
|
||||||
) {
|
) {
|
||||||
// Concurrency stuff. This might happen if the execution finishes
|
// Concurrency stuff. This might happen if the execution finishes
|
||||||
// prior to saving all information to database. Somewhat rare but
|
// prior to saving all information to database. Somewhat rare but
|
||||||
// With auto refresh and several executions, it happens sometimes.
|
// With auto refresh and several executions, it happens sometimes.
|
||||||
// So we replace the execution data so it displays correctly.
|
// So we replace the execution data so it displays correctly.
|
||||||
this.finishedExecutions[executionIndex] = currentItem;
|
alreadyPresentExecutions[executionIndex] = currentItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
@ -646,23 +642,25 @@ export default mixins(externalHooks, genericHelpers, executionHelpers, restApi,
|
||||||
|
|
||||||
// Find the correct position to place this newcomer
|
// Find the correct position to place this newcomer
|
||||||
let j;
|
let j;
|
||||||
for (j = this.finishedExecutions.length - 1; j >= 0; j--) {
|
for (j = alreadyPresentExecutions.length - 1; j >= 0; j--) {
|
||||||
if (currentId < parseInt(this.finishedExecutions[j].id, 10)) {
|
if (currentId < parseInt(alreadyPresentExecutions[j].id, 10)) {
|
||||||
this.finishedExecutions.splice(j + 1, 0, currentItem);
|
alreadyPresentExecutions.splice(j + 1, 0, currentItem);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (j === -1) {
|
if (j === -1) {
|
||||||
this.finishedExecutions.unshift(currentItem);
|
alreadyPresentExecutions.unshift(currentItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.finishedExecutions = this.finishedExecutions.filter(
|
const alreadyPresentExecutionsFiltered = alreadyPresentExecutions.filter(
|
||||||
(execution) =>
|
(execution) =>
|
||||||
!gaps.includes(parseInt(execution.id, 10)) && lastId >= parseInt(execution.id, 10),
|
!gaps.includes(parseInt(execution.id, 10)) && lastId >= parseInt(execution.id, 10),
|
||||||
);
|
);
|
||||||
this.finishedExecutionsCount = results[0].count;
|
this.finishedExecutionsCount = results[0].count;
|
||||||
this.finishedExecutionsCountEstimated = results[0].estimated;
|
this.finishedExecutionsCountEstimated = results[0].estimated;
|
||||||
this.workflowsStore.addToCurrentExecutions(this.finishedExecutions);
|
|
||||||
|
Vue.set(this, 'finishedExecutions', alreadyPresentExecutionsFiltered);
|
||||||
|
this.workflowsStore.addToCurrentExecutions(alreadyPresentExecutionsFiltered);
|
||||||
},
|
},
|
||||||
async loadFinishedExecutions(): Promise<void> {
|
async loadFinishedExecutions(): Promise<void> {
|
||||||
if (this.filter.status === 'running') {
|
if (this.filter.status === 'running') {
|
||||||
|
|
|
@ -326,7 +326,7 @@ export default mixins(
|
||||||
for (let i = fetchedExecutions.length - 1; i >= 0; i--) {
|
for (let i = fetchedExecutions.length - 1; i >= 0; i--) {
|
||||||
const currentItem = fetchedExecutions[i];
|
const currentItem = fetchedExecutions[i];
|
||||||
const currentId = parseInt(currentItem.id, 10);
|
const currentId = parseInt(currentItem.id, 10);
|
||||||
if (lastId !== 0 && isNaN(currentId) === false) {
|
if (lastId !== 0 && !isNaN(currentId)) {
|
||||||
if (currentId - lastId > 1) {
|
if (currentId - lastId > 1) {
|
||||||
const range = _range(lastId + 1, currentId);
|
const range = _range(lastId + 1, currentId);
|
||||||
gaps.push(...range);
|
gaps.push(...range);
|
||||||
|
@ -372,10 +372,8 @@ export default mixins(
|
||||||
if (updatedActiveExecution !== null) {
|
if (updatedActiveExecution !== null) {
|
||||||
this.workflowsStore.activeWorkflowExecution = updatedActiveExecution;
|
this.workflowsStore.activeWorkflowExecution = updatedActiveExecution;
|
||||||
} else {
|
} else {
|
||||||
const activeNotInTheList = !existingExecutions.some(
|
const activeInList = existingExecutions.some((ex) => ex.id === this.activeExecution.id);
|
||||||
(ex) => ex.id === this.activeExecution?.id,
|
if (!activeInList && this.executions.length > 0) {
|
||||||
);
|
|
||||||
if (activeNotInTheList && this.executions.length > 0) {
|
|
||||||
this.$router
|
this.$router
|
||||||
.push({
|
.push({
|
||||||
name: VIEWS.EXECUTION_PREVIEW,
|
name: VIEWS.EXECUTION_PREVIEW,
|
||||||
|
|
Loading…
Reference in a new issue