Skip to content

Commit

Permalink
add sort functionality to subjects and sort by id default
Browse files Browse the repository at this point in the history
  • Loading branch information
Tooyosi committed Jul 11, 2024
1 parent faf9756 commit 234a25a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/controllers/api/v1/subjects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ class Api::V1::SubjectsController < Api::ApiController
before_action :check_subject_limit, only: :create

def index
unless params[:sort]
params[:sort] = 'id'
end

case params[:sort]
when 'queued'
queued
Expand Down
2 changes: 2 additions & 0 deletions app/serializers/subject_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class SubjectSerializer

preload :locations, :project, :collections, :subject_sets

can_sort_by :id

def locations
@model.ordered_locations.map do |loc|
{
Expand Down

0 comments on commit 234a25a

Please sign in to comment.