diff options
Diffstat (limited to 'app/models/timelog.rb')
-rw-r--r-- | app/models/timelog.rb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/app/models/timelog.rb b/app/models/timelog.rb index dc976816ad9..eb72456b435 100644 --- a/app/models/timelog.rb +++ b/app/models/timelog.rb @@ -3,8 +3,9 @@ class Timelog < ApplicationRecord include Importable include IgnorableColumns + include Sortable - ignore_column :note_id_convert_to_bigint, remove_with: '16.0', remove_after: '2023-05-22' + ignore_column :note_id_convert_to_bigint, remove_with: '16.2', remove_after: '2023-07-22' before_save :set_project @@ -45,11 +46,13 @@ class Timelog < ApplicationRecord issue || merge_request end - def self.sort_by_field(field, direction) - if direction == :asc - order_scope_asc(field) - else - order_scope_desc(field) + def self.sort_by_field(field) + case field.to_s + when 'spent_at_asc' then order_scope_asc(:spent_at) + when 'spent_at_desc' then order_scope_desc(:spent_at) + when 'time_spent_asc' then order_scope_asc(:time_spent) + when 'time_spent_desc' then order_scope_desc(:time_spent) + else order_by(field) end end |