-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(core): Optimize SharedWorkflow queries #6297
fix(core): Optimize SharedWorkflow queries #6297
Conversation
Great PR! Please pay attention to the following items before merging: Files matching
Files matching
Make sure to check off this list before asking for review. |
@@ -24,8 +24,6 @@ export async function getSharedWorkflowIds(user: User): Promise<string[]> { | |||
select: ['workflowId'], | |||
}); | |||
return sharedWorkflows.map(({ workflowId }) => workflowId); | |||
|
|||
return sharedWorkflows.map(({ workflowId }) => workflowId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good argument for enabling no-unreachable
linting rule.
@@ -348,30 +345,31 @@ export class ActiveWorkflowRunner { | |||
/** | |||
* Returns the ids of the currently active workflows | |||
*/ | |||
async getActiveWorkflows(user?: User): Promise<IWorkflowDb[]> { | |||
async getActiveWorkflows(user?: User): Promise<string[]> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
async getActiveWorkflows(user?: User): Promise<string[]> { | |
async getActiveWorkflowIds(user?: User): Promise<IWorkflowDb['id'][]> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that'd be an {id:string}
object instead of string[], which for some reason the frontend expects
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #6297 +/- ##
=======================================
Coverage 27.65% 27.65%
=======================================
Files 2948 2948
Lines 180885 180885
Branches 19647 19645 -2
=======================================
Hits 50019 50019
Misses 130119 130119
Partials 747 747
☔ View full report in Codecov by Sentry. |
if (!user || user.globalRole.name === 'owner') { | ||
activeWorkflows = await Db.collections.Workflow.find({ | ||
select: ['id'], | ||
where: { active: true }, | ||
}); | ||
return activeWorkflows.map((workflow) => workflow.id.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is the .toString
needed? this is already handled in the ORM code, and at this point the id
should already be a string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for some reason js turns the string into a number again, which lets the tests fail because we get arrays of [1, '1']
now. so i'm forcing the string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this sounds like a bug that should be fixed, instead of being worked around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be a mix of TypeORM, since on the db level the ids are still INT (which will change very soon), and js type inferance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - n8n is able to start, acitvate and deactivate workflows fine even with the changes. Listing executions also does not seem to have been negatively affected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - n8n is able to start, acitvate and deactivate workflows fine even with the changes. Listing executions also does not seem to have been negatively affected.
✅ All Cypress E2E specs passed |
1 similar comment
✅ All Cypress E2E specs passed |
* allow execution on node 19,20,22 * fix(ERPNext Node): Fix issue with credential test and add frappe cloud url (n8n-io#6283) * fix(editor): UI copy fix for Date & Time node (no-changelog) (n8n-io#6291) * whether -> when * lint fix --------- Co-authored-by: Jonathan Bennetts <jonathan.bennetts@gmail.com> * feat(RabbitMQ Node): Add mode for acknowledging and deleting from queue later in workflow (n8n-io#6225) * Add later in workflow mode * Add new operation * Acknowledge message in next node * Add response and emit for responsePromiseHook * Remove double success message, close channel correctly * Answser messages correctly * Remove option from delete operation * move operation name to camelCase * Fix versioning * To remove: add action item in v1 * Add notice for delete from queue * Correctly only execute only the delete operation * Refactor delete from queue operator and add return last items --------- Co-authored-by: Marcus <marcus@n8n.io> * feat: Add dangerouslyUseHTMLString where needed (no-changelog) (n8n-io#6292) feat: add dangerouslyUseHTMLString where needed (no-changelog) * fix(Wekan Node): Handle response correctly (n8n-io#6296) Fix bug when response wasn't array * Added procfile * Added procfile * redployed * redployed * redployed * redployed * redployed * redployed * dont start * redployed * redployed * update version * redployed * redployed * redployed * redployed * Revert "update version" This reverts commit c249585. * add heroku stack version * delete * add app.json setting heroku build stack * update * update vite * update mem * update PORT * redployed * fix(core): Optimize SharedWorkflow queries (n8n-io#6297) * optimize SharedWorkflow queries * fix int to string ids * fix(Strapi Node): Strapi credentials notice (n8n-io#6289) * fix(SSH Node): Private key field as password and credential test (n8n-io#6298) * fix: Prevent removing manual executions when setting says to save (n8n-io#6300) * fix: Initialize license in queue mode correctly (n8n-io#6301) * feat(Ldap Node): Add LDAP node (n8n-io#4783) * feat(LoneScale Node): Add LoneScale node and Trigger node (n8n-io#5146) * feat: Add SSO SAML metadataUrl support and various improvements (n8n-io#6139) * feat: add various sso improvements * fix: remove test button assertion * fix: fix type imports * test: attempt fixing unit tests * fix: changed to using useToast for error toasts * Minor copy tweaks and swapped buttons position. * fix locale ref * align error with UI wording * simplify saving ux * fix pretty * fix: update saml sso setting saving * fix: undo try/catch changes when saving saml config * metadata url tab selected at first * chore: fix linting issue * test: fix activation checkbox test --------- Co-authored-by: Giulio Andreini <g.andreini@gmail.com> Co-authored-by: Michael Auerswald <michael.auerswald@gmail.com> Co-authored-by: Romain Minaud <romain.minaud@gmail.com> * fix(editor): Fix canvas loading when page gets restored from bfcache (n8n-io#6304) * fix(editor): Fix canvas loading when page gets restored from bfcache * Lint fix * fix(editor): Link to log streaming doc from log streaming (no-changelog) (n8n-io#6303) link to log streaming doc from log streaming --------- Co-authored-by: Eyal Fishler <eyalfishler@gmail.com> Co-authored-by: Jon <jonathan.bennetts@gmail.com> Co-authored-by: Deborah <deborah@starfallprojects.co.uk> Co-authored-by: agobrech <45268029+agobrech@users.noreply.github.com> Co-authored-by: Marcus <marcus@n8n.io> Co-authored-by: Alex Grozav <alex@grozav.com> Co-authored-by: Omri Attoun <omri@joyous.team> Co-authored-by: Michael Auerswald <michael.auerswald@gmail.com> Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com> Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: Yann ALEMAN <yann.aleman27@gmail.com> Co-authored-by: Giulio Andreini <g.andreini@gmail.com> Co-authored-by: Romain Minaud <romain.minaud@gmail.com> Co-authored-by: OlegIvaniv <me@olegivaniv.com>
|
Got released with |
No description provided.