-
Notifications
You must be signed in to change notification settings - Fork 30
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
Sai Venkatesh- Backend - Improve speed and function of deleting multiple blue squares #1130
Conversation
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.
Just remove some of the comments to clean things up and I'll approve. The code refactor looks good.
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.
Refactoring existing backend code, tested and should be ready to merge. Before that, please kindly remove all the unnecessary comments from the code.
Also, as mentioned in the corresponding frontend PR, please kindly branching out in this repo instead of a forked one. Thanks!
In the code refactor, a try-catch block is used for all code within the function. what If the .save() method fails, it should be handled either in a specific try-catch block or by using a callback function. |
Consolidated Destructuring for Props Simplified handleOnClick by Reducing Repeated Conditions Benefit: This makes the logic easier to follow, reduces unnecessary branches, and ensures quicker execution when deleting. Although the performance improvement is minimal, cleaner logic reduces the chance of bugs, making the delete functionality more reliable and easier to optimize in the future. Moved Formatting Logic Inside JSX Benefit: This minimizes unnecessary intermediate logic and lets React handle the rendering more efficiently. This doesn’t directly speed up the deletion but makes rendering the component more efficient, especially in complex UIs with lots of elements. By reducing unnecessary overhead in rendering, React can potentially free up resources faster when performing state updates like deletion. Removed Redundant Conditions and Comments Better Maintainability: Cleaner code is easier to modify and optimize. If you ever need to further optimize the delete functionality (e.g., through better state management or using React.memo to prevent unnecessary re-renders), having a cleaner base will make these optimizations more effective and easier to implement. If you still feel it doesn't improve the speed, feel free to suggest changes. |
@Ankuriboh |
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.
…and-function-of-deleting-multiple-blue-squares
Thank you all, merging! |
424ca84
into
OneCommunityGlobal:development
Description
Blue squares used to come back, now they just delete really slowly or not at all
Related PRS (if any):
This backend PR is related to the #2774 frontend PR.
…
Main changes explained:
Used async/await consistently, removing the callback approach from findById.
Simplified error handling by wrapping the entire block in a try/catch.
Replaced redundant return statements with direct res responses for permission and record checks.
Improved readability and structure by removing unnecessary comments and logs.
…
How to test:
npm install
and...
to run this PR locallyhttps://www.loom.com/share/02a9fd342bf84425abdf547566c85035