Skip to content

Conversation

@karrui
Copy link
Collaborator

@karrui karrui commented Nov 13, 2024

TL;DR

Simplified user data retrieval by using existing context data instead of making a database query.

What changed?

Removed the database query in the me.router.ts file and directly returned the user data from the context (ctx.user) that's already available through the protectedProcedure.

How to test?

  1. Make a request to the /me endpoint while authenticated
  2. Verify that the user data is still returned correctly
  3. Confirm that the response time has improved due to the eliminated database query

Why make this change?

The protectedProcedure already includes the necessary user data in its context, making the additional database query redundant. This change improves performance by eliminating an unnecessary database call while maintaining the same functionality.

@vercel
Copy link

vercel bot commented Nov 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
starter-kit ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 13, 2024 7:59am

Copy link
Collaborator Author

karrui commented Nov 13, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @karrui and the rest of your teammates on Graphite Graphite

@karrui karrui marked this pull request as ready for review November 13, 2024 07:58
@karrui karrui requested a review from AikoPath November 13, 2024 07:58
Copy link
Contributor

@AikoPath AikoPath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 👍

@datadog-opengovsg
Copy link

datadog-opengovsg bot commented Nov 13, 2024

Datadog Report

Branch report: 11-13-feat_remove_redundant_db_query_in_me.get
Commit report: 891d57e
Test service: starter-kit

✅ 0 Failed, 11 Passed, 0 Skipped, 10.37s Total Time
➡️ Test Sessions change in coverage: 1 no change

@karrui karrui merged commit 6262119 into main Nov 13, 2024
13 checks passed
@karrui karrui deleted the 11-13-feat_remove_redundant_db_query_in_me.get branch November 13, 2024 08:03
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