summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2015-08-16 18:05:53 -0700
committerStan Hu <stanhu@gmail.com>2015-08-20 01:38:15 -0700
commit98eb89be5d2df31c31812e670f058afc0454c865 (patch)
treeafc4fb0d97a3d356b65d997dcdd8590d32fdc435 /app
parent55fc58bda4a5592f2f8deaecec9526fbe4eecd6f (diff)
downloadgitlab-ce-98eb89be5d2df31c31812e670f058afc0454c865.tar.gz
Only show recent push event if the branch still exists or a recent merge request has not been created
Closes #2277
Diffstat (limited to 'app')
-rw-r--r--app/models/user.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 57145cc6b6e..f70761074c5 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -471,8 +471,19 @@ class User < ActiveRecord::Base
events = recent_events.code_push.where("created_at > ?", Time.now - 2.hours)
events = events.where(project_id: project_id) if project_id
- # Take only latest one
- events = events.recent.limit(1).first
+ # Use the latest event that has not been pushed or merged recently
+ events.recent.find do |event|
+ project = Project.find_by_id(event.project_id)
+ next unless project
+ repo = project.repository
+
+ if repo.branch_names.include?(event.branch_name)
+ merge_requests = MergeRequest.where("created_at >= ?", event.created_at).
+ where(source_project_id: project.id,
+ source_branch: event.branch_name)
+ merge_requests.empty?
+ end
+ end
end
def projects_sorted_by_activity