This commit is contained in:
yystopf 2023-02-23 16:18:09 +08:00
parent 7cb2321c02
commit dc01d7fc3e
1 changed files with 8 additions and 3 deletions

View File

@ -70,11 +70,16 @@ class Api::V1::Issues::MilestonesController < Api::V1::BaseController
end
def sort_by
Version.columns.include?(params.fetch(:sort_by, "created_on")) ? params.fetch(:sort_by, "created_on") : "created_on"
sort_by = params.fetch(:sort_by, "created_on")
sort_by = Version.column_names.include?(sort_by) ? sort_by : "created_on"
sort_by
end
def sort_direction
%w(desc asc).include?(params.fetch(:sort_direction, "desc")) ? params.fetch(:sort_direction, "desc") : "desc"
def sort_direction
sort_direction = params.fetch(:sort_direction, "desc").downcase
sort_direction = %w(desc asc).include?(sort_direction) ? sort_direction : "desc"
sort_direction
end
end