-
Notifications
You must be signed in to change notification settings - Fork 41
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
add sort functionality to subjects and sort by id default #4359
Conversation
Apologies for the delay. I think defaulting sort by id this way is fine for now. See benchmark comparison. (It looks like adding sort adds a bit of a difference in terms of latency, but not enough to discourage this idea. Using a subject set with 818884 subjects, running specific GET requests 1000 times. For me the "real" value is what I use for comparison. Real value is value in parens ).
Some things to note:
|
@@ -13,6 +13,10 @@ class Api::V1::SubjectsController < Api::ApiController | |||
before_action :check_subject_limit, only: :create | |||
|
|||
def index | |||
unless params[:sort] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a quick test for this change on the controller
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick change: I would add a test to ensure params default is sort.
Later on, we can think about updating restpack_serializer to allow sorting defaults, so we don't have to manually set default sorting by setting params.
(My thought off the bat:
Maybe add a method
default_sort_by
and an attr default_sorting_attribute
to sortable.rb ,
then within #sorting_from_params
options.rb method set sort_values to default_sorting_attribute.
Then in our serializers in panoptes, when we set can_sort_by
we can also set default_sort_by
. (Note this is me brainstorming, I have not tested this theory).
Implement sort functionality to subjects index controller and make sort by id default
Review checklist
apiary.apib
file?