Skip to content

Augment user API to allow easier access to user preferences - #2890

Merged
gwprice merged 2 commits into
masterfrom
gprice/user-api-with-prefs
Mar 11, 2014
Merged

Augment user API to allow easier access to user preferences#2890
gwprice merged 2 commits into
masterfrom
gprice/user-api-with-prefs

Conversation

@gwprice

@gwprice gwprice commented Mar 10, 2014

Copy link
Copy Markdown

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Actually, I think this could be rewritten to take full advantage of prefetch_related, but it would still have the aforementioned disadvantage.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

i'm cool to leave the code where it is, and add a task to our story to check the performance.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I modified this in such a way that we can try adding prefetch_related as an optimization if we need to.

@gwprice

gwprice commented Mar 11, 2014

Copy link
Copy Markdown
Author

Updated

Comment thread common/djangoapps/user_api/views.py Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

should prefetch_related happen here too?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

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).
@jimabramson

Copy link
Copy Markdown

👍

gwprice pushed a commit that referenced this pull request Mar 11, 2014
Augment user API to allow easier access to user preferences
@gwprice
gwprice merged commit 654239d into master Mar 11, 2014
@gwprice
gwprice deleted the gprice/user-api-with-prefs branch March 11, 2014 17:37
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