diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-02-19 11:43:41 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-02-19 11:43:41 +0400 |
commit | bfc359ca61bd7e7ffea714b4ad64a7d9927441c3 (patch) | |
tree | 27d193c8f51add1bd153054f5273bac72312e49f /app | |
parent | ba937b2b3d81a7a9d3097387150fe8c8f2d784ca (diff) |
Fix project filter for MR on dashboard
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/dashboard_helper.rb | 2 | ||||
-rw-r--r-- | app/models/issue.rb | 10 | ||||
-rw-r--r-- | app/models/merge_request.rb | 17 | ||||
-rw-r--r-- | app/models/user.rb | 2 |
4 files changed, 22 insertions, 9 deletions
diff --git a/app/helpers/dashboard_helper.rb b/app/helpers/dashboard_helper.rb index c759dffa16e..e3be07c9fe0 100644 --- a/app/helpers/dashboard_helper.rb +++ b/app/helpers/dashboard_helper.rb @@ -27,6 +27,6 @@ module DashboardHelper items.opened end - items.where(assignee_id: current_user.id).count + items.cared(current_user).count end end diff --git a/app/models/issue.rb b/app/models/issue.rb index 07c0401143c..04c2df059a9 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -24,7 +24,13 @@ class Issue < ActiveRecord::Base acts_as_taggable_on :labels - def self.open_for(user) - opened.assigned(user) + class << self + def cared(user) + where('assignee_id = :user', user: user.id) + end + + def open_for(user) + opened.assigned(user) + end end end diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 345b8d6e07d..ac7c9f74ff0 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -43,12 +43,19 @@ class MergeRequest < ActiveRecord::Base validates :target_branch, presence: true validate :validate_branches - def self.find_all_by_branch(branch_name) - where("source_branch LIKE :branch OR target_branch LIKE :branch", branch: branch_name) - end - def self.find_all_by_milestone(milestone) - where("milestone_id = :milestone_id", milestone_id: milestone) + class << self + def cared(user) + where('assignee_id = :user OR author_id = :user', user: user.id) + end + + def find_all_by_branch(branch_name) + where("source_branch LIKE :branch OR target_branch LIKE :branch", branch: branch_name) + end + + def find_all_by_milestone(milestone) + where("milestone_id = :milestone_id", milestone_id: milestone) + end end def human_state diff --git a/app/models/user.rb b/app/models/user.rb index a42671ea1c7..4ed31c7edce 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -267,7 +267,7 @@ class User < ActiveRecord::Base end def cared_merge_requests - MergeRequest.where("author_id = :id or assignee_id = :id", id: self.id) + MergeRequest.cared(self) end # Remove user from all projects and |