diff options
author | Robert Speicher <robert@gitlab.com> | 2016-08-24 20:28:00 +0300 |
---|---|---|
committer | Ruben Davila <rdavila84@gmail.com> | 2016-08-25 01:38:35 +0300 |
commit | 7c9afd19b752cc7d775c7062f7078e230532156a (patch) | |
tree | a3b46e04fd1ba78e7470dbdbf45ce020eabefa8a /app | |
parent | f7a4dfe517036b1dfd62d3dd8c51c2254a0b0fa3 (diff) |
Merge branch '20254-create-mr-for-new-branch' into 'master'
last_push_event widget considers fork events on the main project
Push events on the fork of the current project are considered to be shown besides the push events on the current project. Before we just consider fork events if exists a fork so we miss current project events if the current user has a fork.
Closes #20254
See merge request !5978
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/projects_helper.rb | 21 | ||||
-rw-r--r-- | app/models/user.rb | 4 |
2 files changed, 13 insertions, 12 deletions
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 249d18c4486..356f27f2d5d 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -116,6 +116,17 @@ module ProjectsHelper license.nickname || license.name end + def last_push_event + return unless current_user + + project_ids = [@project.id] + if fork = current_user.fork_of(@project) + project_ids << fork.id + end + + current_user.recent_push(project_ids) + end + private def get_project_nav_tabs(project, current_user) @@ -351,16 +362,6 @@ module ProjectsHelper namespace_project_new_blob_path(@project.namespace, @project, tree_join(ref), file_name: 'LICENSE') end - def last_push_event - return unless current_user - - if fork = current_user.fork_of(@project) - current_user.recent_push(fork.id) - else - current_user.recent_push(@project.id) - end - end - def readme_cache_key sha = @project.commit.try(:sha) || 'nil' [@project.path_with_namespace, sha, "readme"].join('-') diff --git a/app/models/user.rb b/app/models/user.rb index 48e83ab7e56..ad3cfbc03e4 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -489,10 +489,10 @@ class User < ActiveRecord::Base (personal_projects.count.to_f / projects_limit) * 100 end - def recent_push(project_id = nil) + def recent_push(project_ids = nil) # Get push events not earlier than 2 hours ago events = recent_events.code_push.where("created_at > ?", Time.now - 2.hours) - events = events.where(project_id: project_id) if project_id + events = events.where(project_id: project_ids) if project_ids # Use the latest event that has not been pushed or merged recently events.recent.find do |event| |