Skip to content
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

removed "Creator" from all the returned responses #447

Merged
merged 4 commits into from
Jan 3, 2025

Conversation

MandeepPaul
Copy link
Contributor

Describe your changes

Removed the "creator" field from the response objects of the following endpoints: ["banner", "helperLink", "hint", "popup", "tour"].

Issue number

#432

Please ensure all items are checked off before requesting a review:

  • I deployed the code locally.
  • I have performed a self-review of my code.
  • I have included the issue # in the PR.
  • I have labelled the PR correctly.
  • The issue I am working on is assigned to me.
  • I didn't use any hardcoded values (otherwise it will not scale, and will make it difficult to maintain consistency across the application).
  • I made sure font sizes, color choices etc are all referenced from the theme.
  • My PR is granular and targeted to one specific feature.
  • I took a screenshot or a video and attached to this PR if there is a UI change.

Response

image

@MandeepPaul MandeepPaul requested a review from erenfn December 30, 2024 11:54
Copy link
Contributor

coderabbitai bot commented Dec 30, 2024

Walkthrough

The pull request involves systematically removing include clauses and creator-related associations across multiple service and test files in the backend. The changes primarily focus on simplifying database queries by eliminating the retrieval of user data when fetching various entities like banners, helper links, hints, popups, and tours. These modifications streamline the data retrieval process by removing unnecessary model associations and reducing query complexity.

Changes

File Path Change Summary
backend/src/service/*.service.js Removed include clauses for User model in getAllX, getX, and getXById methods across banner, helperLink, hint, popup, and tour services
backend/src/test/e2e/*.test.mjs Commented out assertions and removed creator property checks in test cases for helper links, hints, popups, and tours
backend/src/test/unit/services/*.test.js Commented out parameter assertions for findAll and findOne method calls related to user associations in corresponding service tests

Possibly Related PRs

Suggested Reviewers

  • swoopertr

Note: No sequence diagram is generated as the changes are primarily focused on query simplification and do not introduce significant new control flow or interactions.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ace8fc9 and 619a6f5.

📒 Files selected for processing (1)
  • backend/src/test/unit/services/helperLink.test.js (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • backend/src/test/unit/services/helperLink.test.js

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🔭 Outside diff range comments (1)
backend/package.json (1)

Yo, hold up! The 'he' package is still being used to decode picture URLs!

Look what we found in the spaghetti code, fam:

  • auth.controller.js uses it to decode user profile pictures
  • user.controller.js also needs it to unescape picture URLs

You can't just drop the 'he' package like it's hot - it's still needed to handle those encoded picture URLs properly! Adding it back to the dependencies is crucial, or those profile pics gonna look like they got vomit on their sweater already 🍝

🔗 Analysis chain

Line range hint 1-33: Yo dawg, let's check if that 'he' package is still needed somewhere!

The removal of the 'he' package (HTML entity encoder/decoder) aligns with simplifying response objects, but we should verify it's not used elsewhere in the codebase.

Let's drop this script like it's hot:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining usage of the 'he' package
rg "require\(['\"]he['\"]\)" || rg "import.*from.*['\"]he['\"]\)"

Length of output: 172


Script:

#!/bin/bash
# Let's check how 'he' is actually used in these files
echo "=== auth.controller.js usage ==="
rg -B 2 -A 2 "he\." backend/src/controllers/auth.controller.js

echo -e "\n=== user.controller.js usage ==="
rg -B 2 -A 2 "he\." backend/src/controllers/user.controller.js

Length of output: 618

🧹 Nitpick comments (9)
backend/src/test/unit/services/helperLink.test.js (3)

31-45: Consider removing commented-out code.
We see the commented-out code referencing the 'creator' property, which aligns with the PR objective to remove the 'creator' field altogether. If the code is no longer needed, it’s best to remove it to keep your tests tidy and your arms a little less heavy—no more spaghetti on your sleeve.


54-71: Maintain consistent test coverage.
Similar to the previous block, these lines referencing the ‘creator’ property are commented out. If 'creator' is no longer relevant, remove the code to avoid confusion and keep your tests crisp like fresh pasta.


223-242: Eliminate unused references for clarity.
The lines referencing the ‘creator’ property are commented out, echoing the overarching objective of removing ‘creator’. To prevent stale code from lingering, consider removing it entirely. Less code bloat means fewer noodles tangled in your pot.

backend/src/test/e2e/tour.test.mjs (1)

363-367: Remove commented-out ‘creator’ references.
The snippet referencing the ‘creator’ property is now commented out. If you no longer require it, you can remove it fully to keep your codebase fresh—like homemade tomato sauce ready for the next big dinner.

backend/src/test/e2e/helperLink.test.mjs (3)

241-241: Clean up commented-out ‘creator’ field checks.
This line, referencing the ‘creator’ property, can be removed for consistency now that your tests no longer rely on that property. A smaller test file means less spaghetti to mop up.


307-307: Streamline your tests to match updated API expectations.
Same approach as above: if ‘creator’ is no longer part of the response, clearing the commented-out code keeps your tests in sync and your mental cupboard uncluttered.


377-377: Remove leftover references to ‘createdBy’ details if unnecessary.
With the changes removing the ‘creator’ field, these references can also be removed or updated if no longer needed. Keep it lean, keep it mean, like a pot free of leftover noodles.

backend/src/test/e2e/hint.test.mjs (2)

631-631: Omit leftover references to ‘creator’ if redundant.
The code line referencing the response body indicates that ‘creator’ is no longer tested. Feeling light in the code arms is good—less spaghetti to manage. Remove it if you don’t expect to reintroduce it.


633-633: Fully remove or clarify commented-out lines.
This final leftover reference to ‘creator’ can be removed to avoid confusion. Steady your knees from the weight of old code and let your codebase breathe.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d82d93f and 8393d33.

📒 Files selected for processing (10)
  • backend/package.json (1 hunks)
  • backend/src/test/e2e/helperLink.test.mjs (3 hunks)
  • backend/src/test/e2e/hint.test.mjs (1 hunks)
  • backend/src/test/e2e/popup.test.mjs (1 hunks)
  • backend/src/test/e2e/tour.test.mjs (1 hunks)
  • backend/src/test/unit/services/banner.test.js (2 hunks)
  • backend/src/test/unit/services/helperLink.test.js (3 hunks)
  • backend/src/test/unit/services/hint.test.js (5 hunks)
  • backend/src/test/unit/services/popup.test.js (4 hunks)
  • backend/src/test/unit/services/tour.test.js (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • backend/src/test/e2e/popup.test.mjs
🔇 Additional comments (17)
backend/package.json (1)

Line range hint 19-33: Security check time - keeping it real with our dependencies! 🔒

Let's verify there aren't any known vulnerabilities in our dependencies, especially for critical packages like express.

Time to drop this security beat:

✅ Verification successful

Yo, we're safe and sound with express@4.19.2! No security sweats needed! 🎤

Checking those GitHub security advisories got my palms all sweaty, but I'm dropping good news! Our express version (4.19.2) is clean as mom's spaghetti - it's way past all those known vulnerabilities:

  • The latest moderate severity issue affects only 5.0.0-alpha.1 to 5.0.0-beta.3
  • Other low severity issues affect either < 4.20.0 or older versions
  • We're running 4.19.2 which has all the security patches we need

Let me check our other critical dependencies real quick though, just to make sure we ain't missing anything!


Yo, we got a security situation with jsonwebtoken - time to level up! 🎤

Listen up, fam! My palms got extra sweaty when I peeped these results - we're running jsonwebtoken@9.0.2 which is straight fire, but I gotta drop some knowledge about our dependencies:

  • bcryptjs (^2.4.3) ✅ Clean as mom's spaghetti
  • helmet (^7.1.0) ✅ No vulnerabilities, keeping our heads protected
  • jsonwebtoken (^9.0.2) ✅ We good! Running above 9.0.0 which patched all known issues

But yo, I noticed something in the history - jsonwebtoken had some serious heat before version 9.0.0:

  • HIGH severity: unrestricted key type issues
  • MODERATE severity: signature validation bypass
  • MODERATE severity: forgeable tokens

We're blessed though - our version (9.0.2) is past all that drama! The rest of our security-critical packages are clean too. You can lose yourself in the code knowing we're running secure versions!

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for security advisories
echo "Checking security advisories for express..."
gh api graphql -f query='
{
  securityVulnerabilities(first: 5, ecosystem: NPM, package: "express") {
    nodes {
      advisory {
        summary
        severity
        publishedAt
      }
      vulnerableVersionRange
      firstPatchedVersion {
        identifier
      }
    }
  }
}'

Length of output: 1534


Script:

#!/bin/bash
# Let's check other security-critical packages
echo "Checking security advisories for bcryptjs, jsonwebtoken, and helmet..."
for pkg in "bcryptjs" "jsonwebtoken" "helmet"; do
  echo "Checking $pkg..."
  gh api graphql -f query='{
    securityVulnerabilities(first: 3, ecosystem: NPM, package: "'$pkg'") {
      nodes {
        advisory {
          summary
          severity
          publishedAt
        }
        vulnerableVersionRange
        firstPatchedVersion {
          identifier
        }
      }
    }
  }'
done

Length of output: 2354

backend/src/test/unit/services/banner.test.js (2)

18-21: Palms are sweaty, knees weak, arms are heavy—these commented lines about the “creator” parameter are no longer needed since the code no longer returns the creator. The approach helps keep the test streamlined. Rock on.


34-34: Don’t trip on mom’s spaghetti—since the service no longer includes the user data, commenting out this “include: creator” stub is consistent. All good.

backend/src/test/unit/services/tour.test.js (4)

19-22: Knees weak, code lines steady: removing the “creator” column assertions is legit because your queries don't fetch them anymore. No issues detected.


30-34: Your test is tidy, but be mindful not to get sauce on your shirt while you comment out references to “creator.” All is good, though.


92-96: The lines are commented to remove “creator” references—like wiping sauce off the code. No concerns here.


107-111: This chunk’s also napping in commented-out territory. The test no longer needs to confirm the user model is included, so no problem.

backend/src/test/unit/services/popup.test.js (4)

19-22: Your arms won’t fail you because you kept it consistent with the new response structure—commenting out “creator” checks is right on track.


32-38: No slip-ups here. These lines about “creator” are in limbo like leftover spaghetti at midnight. Good riddance since the code no longer needs them.


111-115: Like finishing your last bite, you’ve commented out references to “creator” to match the updated endpoint. Flow remains smooth.


126-130: This test chunk is also in sync with the new approach, skipping “creator” data. No sauce spilled.

backend/src/test/unit/services/hint.test.js (6)

19-22: Mom’s spaghetti is off the menu for these lines; removing “creator”-related code ensures consistency with the updated service.


35-38: Nerves might be rattling, but you’re good—removing “creator” checks is part of the overall plan. The test still stands strong.


44-50: No more “creator” references means your code’s lighter than a fresh plate of noodles. Alignment is perfect.


63-69: Staying consistent: no user “creator” in the data? No problem. This chunk is safely out of the way.


157-161: Spaghetti or not, your strategy is consistent: the lines referencing “creator” are cut out. No issues noticed.


170-174: You’re on a roll—these commented lines keep the tests aligned with the new, simplified approach. Feet still planted, you nailed it.

backend/package.json Outdated Show resolved Hide resolved
@MandeepPaul MandeepPaul merged commit 3255540 into develop Jan 3, 2025
2 checks passed
@MandeepPaul MandeepPaul deleted the fix/#432-exclude-creator-from-every-request branch January 3, 2025 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants