[refs #579] ugly sorting common pull comments
This commit is contained in:
parent
1ee9e3f00e
commit
fb1288e382
|
@ -1,9 +1,11 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
module PullRequestHelper
|
||||
def merge_activity comments, commits
|
||||
pull_comments = comments.group_by(&:data).map{|data, c| [c.first.created_at, [data || {}, [c].flatten]]}
|
||||
commits = @commits.map{ |c| [(c.committed_date || c.authored_date), c] }
|
||||
(pull_comments + commits).sort_by{ |c| c[0] }.map{ |c| c[1] }
|
||||
common_comments, pull_comments = comments.partition {|c| c.data.blank?}
|
||||
common_comments = common_comments.map{ |c| [c.created_at, c] }
|
||||
pull_comments = pull_comments.group_by(&:data).map{|data, c| [c.first.created_at, [data || {}, [c].flatten]]}
|
||||
commits = commits.map{ |c| [(c.committed_date || c.authored_date), c] }
|
||||
(common_comments + pull_comments + commits).sort_by{ |c| c[0] }.map{ |c| c[1] }
|
||||
end
|
||||
|
||||
def pull_status_label pull
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
%a{ :name => "comments" }
|
||||
.hr
|
||||
%h3#block-list= t("layout.comments.comments_header")
|
||||
|
||||
- commits_queue = []
|
||||
- merge_activity(@comments, @commits).each do |item| #
|
||||
- if item.is_a? Grit::Commit
|
||||
-commits_queue << item
|
||||
- elsif item.is_a? Array
|
||||
= render 'projects/git/commits/commits_small', :commits => commits_queue if commits_queue.present?
|
||||
-commits_queue = []
|
||||
-merge_activity(@comments, @commits).each do |item| #
|
||||
-if item.is_a? Comment
|
||||
=render 'projects/git/commits/commits_small', :commits => commits_queue if commits_queue.present?
|
||||
-commits_queue.clear
|
||||
= render 'projects/pull_requests/discussion_comments', :item => item, :project => @project, :commentable => @issue, :add_id => nil
|
||||
= render 'projects/git/commits/commits_small', :commits => commits_queue if commits_queue.present?
|
||||
=render 'projects/comments/comment', :comment => item, :data => {:project => @project, :commentable => @commentable}
|
||||
-elsif item.is_a? Grit::Commit
|
||||
-commits_queue << item
|
||||
-elsif item.is_a? Array
|
||||
=render 'projects/git/commits/commits_small', :commits => commits_queue if commits_queue.present?
|
||||
-commits_queue.clear
|
||||
=render 'projects/pull_requests/discussion_comments', :item => item, :project => @project, :commentable => @issue, :add_id => nil
|
||||
=render 'projects/git/commits/commits_small', :commits => commits_queue if commits_queue.present?
|
||||
|
||||
|
|
Loading…
Reference in New Issue