-
Notifications
You must be signed in to change notification settings - Fork 204
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
Remove checks from monitor query #844
Conversation
Caution Review failedThe pull request is closed. WalkthroughThe pull request introduces modifications to the Changes
Possibly related PRs
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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.
Actionable comments posted: 1
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (3)
- Client/src/Pages/Incidents/index.jsx (1 hunks)
- Server/controllers/monitorController.js (0 hunks)
- Server/db/mongo/modules/monitorModule.js (1 hunks)
Files not reviewed due to no reviewable changes (1)
- Server/controllers/monitorController.js
Additional comments not posted (3)
Client/src/Pages/Incidents/index.jsx (1)
31-31
: Yo, this change is straight fire, dawg! 🔥Setting the limit to
-1
to prevent checks from being returned is a slick move. It's gonna make the Incidents page load faster than Eminem spittin' bars.Server/db/mongo/modules/monitorModule.js (2)
379-383
: Yo, this early return is straight fire, homie! 🔥When
limit
is set to-1
, it's a signal that we don't want any checks. This slick move lets the function bounce early, skipping all that extra processing. It's like a shortcut to the finish line, you feel me?The logic is tight, and the syntax is on point. This change is gonna make the function run faster than Usain Bolt when checks aren't needed. 🏃💨
385-386
: This defaultlimit
value is the real MVP! 🏆When
limit
isundefined
, setting it to0
is like giving the green light to return all the checks. It's the ultimate fallback plan, ensuring that nothing gets left behind.The logic is solid, and the syntax is clean. This change makes the function more flexible than a yoga instructor, allowing it to adapt to any situation. 🧘♀️
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null | ||
); | ||
console.log(res.data.data); |
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.
Hold up, homie! You forgot to clean up your spaghetti code. 🍝
I know you added that console.log
to help with debugging, but leaving it in production is like leaving your dirty laundry on stage during a rap battle. It's a big no-no!
Make sure to remove it before deploying, or you might end up exposing sensitive info like your mom's spaghetti recipe. 🤫
-console.log(res.data.data);
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
console.log(res.data.data); |
This PR fixes the slow loading of the Incidents page. The issue was I originally designed that endpoint to return checks with the monitors. The lazy solution was to set the limit to one and only return one check, but that solution isn't sufficient when large numbers of montiors are present. Solution is to set limit to -1 and return no checks, avoiding the
Promise.all
which runs a query for every monitor.-1
to avoid appending checks to monitors when not needed-1
for limit.