diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-03-22 13:55:00 -0700 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-03-22 13:55:00 -0700 |
commit | 43afe46bbd19b1edf60abf3f104fb2b0d29af564 (patch) | |
tree | e2a11249408e3403a5a125c50008e77ba1157e57 /lib | |
parent | 20a12438ab470afe1a5736fc46091a6ef4c30073 (diff) | |
download | gitlab-ce-43afe46bbd19b1edf60abf3f104fb2b0d29af564.tar.gz |
Refactor contributions events and write tests for calendar
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/contributions_calendar.rb | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/lib/gitlab/contributions_calendar.rb b/lib/gitlab/contributions_calendar.rb index 8ca5115d43a..ea41644811f 100644 --- a/lib/gitlab/contributions_calendar.rb +++ b/lib/gitlab/contributions_calendar.rb @@ -14,7 +14,7 @@ module Gitlab date_from = 1.year.ago date_to = Date.today - events = Event.where(author_id: user.id).where(action: event_type). + events = Event.contributions.where(author_id: user.id). where("created_at > ?", date_from).where(project_id: projects) grouped_events = events.to_a.group_by { |event| event.created_at.to_date.to_s } @@ -41,7 +41,7 @@ module Gitlab end def events_by_date(date) - events = Event.where(author_id: user.id).where(action: event_type). + events = Event.contributions.where(author_id: user.id). where("created_at > ? AND created_at < ?", date.beginning_of_day, date.end_of_day). where(project_id: projects) @@ -57,9 +57,5 @@ module Gitlab def starting_month Date.today.strftime("%m").to_i end - - def event_type - [Event::PUSHED, Event::CREATED, Event::CLOSED, Event::MERGED] - end end end |