Skip to content

Commit

Permalink
Change default recording sort order to descending (bigbluebutton#630)
Browse files Browse the repository at this point in the history
  • Loading branch information
shawn-higgins1 authored and jfederico committed Jul 12, 2019
1 parent 85da83f commit c410c0b
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions app/models/concerns/api_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module APIConcern
def format_recordings(api_res, search_params, ret_search_params)
search = search_params[:search] || ""
order_col = search_params[:column] && search_params[:direction] != "none" ? search_params[:column] : "end_time"
order_dir = search_params[:column] && search_params[:direction] != "none" ? search_params[:direction] : "asc"
order_dir = search_params[:column] && search_params[:direction] != "none" ? search_params[:direction] : "desc"

search = search.downcase

Expand Down Expand Up @@ -66,26 +66,26 @@ def filter_recordings(api_res, search)
def sort_recordings(recs, order_col, order_dir)
recs = case order_col
when "end_time"
recs.sort_by { |r| r[:endTime] }
recs.sort_by { |r| r[:endTime] }
when "name"
recs.sort_by do |r|
if !r[:metadata].nil? && !r[:metadata][:name].nil?
r[:metadata][:name].downcase
else
r[:name].downcase
end
end
recs.sort_by do |r|
if !r[:metadata].nil? && !r[:metadata][:name].nil?
r[:metadata][:name].downcase
else
r[:name].downcase
end
end
when "length"
recs.sort_by { |r| r[:playbacks].reject { |p| p[:type] == "statistics" }.first[:length] }
recs.sort_by { |r| r[:playbacks].reject { |p| p[:type] == "statistics" }.first[:length] }
when "users"
recs.sort_by { |r| r[:participants] }
recs.sort_by { |r| r[:participants] }
when "visibility"
recs.sort_by { |r| r[:metadata][:"gl-listed"] }
recs.sort_by { |r| r[:metadata][:"gl-listed"] }
when "formats"
recs.sort_by { |r| r[:playbacks].first[:type].downcase }
else
recs.sort_by { |r| r[:endTime] }
end
recs.sort_by { |r| r[:playbacks].first[:type].downcase }
else
recs.sort_by { |r| r[:endTime] }
end

if order_dir == 'asc'
recs
Expand Down

0 comments on commit c410c0b

Please sign in to comment.