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

Refactor user fetching to remove unnessary joins #454

Closed
annarhughes opened this issue Jun 6, 2024 · 2 comments
Closed

Refactor user fetching to remove unnessary joins #454

annarhughes opened this issue Jun 6, 2024 · 2 comments
Assignees
Labels
complexity: advanced Time needed to do this ticket will be large e.g. 2-3+ days databases Works with databases help wanted Extra attention is needed javascript Pull requests that update Javascript code maintenance Maintenance / chore work priority: high Should be prioritized next week or longer. state: approved Ready to go. Not blocked or pending.

Comments

@annarhughes
Copy link
Member

annarhughes commented Jun 6, 2024

Is your feature request related to a problem?

Most of our backend api requests are related to users, so before the request function is run, we get the current user from the database and make the user data available in the request and following functions. The problem is that for each request, we are calling the user data with joins to all relationships, whilst the related data is not usually required for the current request. E.g. the api request for a user starting a session, does not require the createSessionUser to have access to user.partnerAccess or user.therapySession relationship data, but it is still being requested.

Describe a solution:

  • Remove the joins in getUserByFirebaseId function in user.service.ts so that the userEntity request context only includes the user data with no joins/relations.
  • Ensure no functions are now broken, i.e. any functions that did use the relationships will no longer have access to the required data. Look for functions that use this data by searching for req['userEntity']. I couldnt see any uses of user.relationships but should be double checked.

This change will massively improve the performance of the API and the code complexity and maintainability in future!

@annarhughes annarhughes added complexity: advanced Time needed to do this ticket will be large e.g. 2-3+ days state: blocked Task is blocked. maintenance Maintenance / chore work databases Works with databases labels Jun 6, 2024
@kyleecodes kyleecodes added this to the 04. Maintenance and Testing milestone Jun 6, 2024
@kyleecodes kyleecodes added the help wanted Extra attention is needed label Jul 23, 2024
@eleanorreem eleanorreem added priority: high Should be prioritized next week or longer. state: approved Ready to go. Not blocked or pending. javascript Pull requests that update Javascript code and removed state: blocked Task is blocked. labels Sep 10, 2024
@reidn3r
Copy link
Contributor

reidn3r commented Sep 15, 2024

Could someone assign this to me? Actually, I already made a pull request trying to solve this issue

Copy link

Thank you @reidn3r you have been assigned this issue!
Please follow the directions in our Contributing Guide. We look forward to reviewing your pull request shortly ✨


Support Chayn's mission? ⭐ Please star this repo to help us find more contributors like you!
Learn more about Chayn here and explore our projects. 🌸

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complexity: advanced Time needed to do this ticket will be large e.g. 2-3+ days databases Works with databases help wanted Extra attention is needed javascript Pull requests that update Javascript code maintenance Maintenance / chore work priority: high Should be prioritized next week or longer. state: approved Ready to go. Not blocked or pending.
Development

No branches or pull requests

4 participants