[refs #579] ugly sorting common pull comments

This commit is contained in:
Alexander Machehin 2012-10-15 22:33:16 +06:00
parent 1ee9e3f00e
commit fb1288e382
2 changed files with 17 additions and 14 deletions

View File

@ -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

View File

@ -1,10 +1,11 @@
%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
-if item.is_a? Comment
=render 'projects/git/commits/commits_small', :commits => commits_queue if commits_queue.present?
-commits_queue.clear
=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?