Augment user API to allow easier access to user preferences - #2890
Conversation
There was a problem hiding this comment.
i'm guessing that this new query is going to get executed once at a time for every user that is returned when a list of users is requested. do you know if that's true, and if so, does the framework support any path to optimizing that?
There was a problem hiding this comment.
The only optimization I can think of for this would be to change the queryset to prefetch the preference objects, but that would only have the benefit of warming any relevant caches and could be an overall loss, since it would fetch preferences related to all users (as opposed to just those in the requested page).
There was a problem hiding this comment.
Actually, I think this could be rewritten to take full advantage of prefetch_related, but it would still have the aforementioned disadvantage.
There was a problem hiding this comment.
i'm cool to leave the code where it is, and add a task to our story to check the performance.
There was a problem hiding this comment.
I modified this in such a way that we can try adding prefetch_related as an optimization if we need to.
|
Updated |
There was a problem hiding this comment.
should prefetch_related happen here too?
The endpoint includes the key of the desired preference in the URL and returns the list of users for whom the preference is set (regardless of the value).
|
👍 |
Augment user API to allow easier access to user preferences
@jimabramson