diff options
Diffstat (limited to 'app/models/timelog.rb')
-rw-r--r-- | app/models/timelog.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/app/models/timelog.rb b/app/models/timelog.rb index 048134fbf04..4ddaf6bcb86 100644 --- a/app/models/timelog.rb +++ b/app/models/timelog.rb @@ -8,6 +8,18 @@ class Timelog < ApplicationRecord belongs_to :merge_request, touch: true belongs_to :user + scope :for_issues_in_group, -> (group) do + joins(:issue).where( + 'EXISTS (?)', + Project.select(1).where(namespace: group.self_and_descendants) + .where('issues.project_id = projects.id') + ) + end + + scope :between_dates, -> (start_date, end_date) do + where('spent_at BETWEEN ? AND ?', start_date, end_date) + end + def issuable issue || merge_request end |