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

Open
annarhughes opened this issue Jun 6, 2024 · 0 comments
Open

Refactor user fetching to remove unnessary joins #454

annarhughes opened this issue Jun 6, 2024 · 0 comments
Labels
complexity: advanced Time needed to do this ticket will be large e.g. 2-3+ days databases Works with databases maintenance Maintenance / chore work state: blocked Task is blocked.

Comments

@annarhughes
Copy link
Member

annarhughes commented Jun 6, 2024

Blocked by #453

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
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 maintenance Maintenance / chore work state: blocked Task is blocked.
Projects
Status: To-Do Bloom Backend
Development

No branches or pull requests

2 participants