diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-21 09:09:12 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-21 09:09:12 +0300 |
commit | 4cd1329b80b80890881be6503958612de3cfdd17 (patch) | |
tree | 3f935c51aa87d5072708f7090a7e7b45be642a21 /app/models/timelog.rb | |
parent | 6f2278bd4a548e432b0429a9576ab896460941b2 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/timelog.rb')
-rw-r--r-- | app/models/timelog.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/timelog.rb b/app/models/timelog.rb index 7c394736560..07c61f64f29 100644 --- a/app/models/timelog.rb +++ b/app/models/timelog.rb @@ -35,10 +35,21 @@ class Timelog < ApplicationRecord where('spent_at <= ?', end_time) end + scope :order_scope_asc, ->(field) { order(arel_table[field].asc.nulls_last) } + scope :order_scope_desc, ->(field) { order(arel_table[field].desc.nulls_last) } + def issuable issue || merge_request end + def self.sort_by_field(field, direction) + if direction == :asc + order_scope_asc(field) + else + order_scope_desc(field) + end + end + private def issuable_id_is_present |