Refactor user fetching to remove unnessary joins #454
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.
Milestone
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 touser.partnerAccess
oruser.therapySession
relationship data, but it is still being requested.Describe a solution:
getUserByFirebaseId
function in user.service.ts so that theuserEntity
request context only includes the user data with no joins/relations.req['userEntity']
. I couldnt see any uses ofuser.relationships
but should be double checked.This change will massively improve the performance of the API and the code complexity and maintainability in future!
The text was updated successfully, but these errors were encountered: