per line comments display

This commit is contained in:
Dmitriy Zaporozhets 2012-01-10 22:08:46 +02:00
parent c66bc99fb7
commit 9da4d06a87
7 changed files with 78 additions and 2 deletions

View file

@ -53,6 +53,23 @@ class Note < ActiveRecord::Base
noteable
end
end
def line_file_id
@line_file_id ||= line_code.split("_")[1].to_i if line_code
end
def line_type_id
@line_type_id ||= line_code.split("_").first if line_code
end
def line_number
@line_number ||= line_code.split("_").last.to_i if line_code
end
def for_line?(file_id, old_line, new_line)
line_file_id == file_id &&
((line_type_id == "NEW" && line_number == new_line) || (line_type_id == "OLD" && line_number == old_line ))
end
end
# == Schema Information
#

View file

@ -166,7 +166,11 @@ class Project < ActiveRecord::Base
end
def commit_notes(commit)
notes.where(:noteable_id => commit.id, :noteable_type => "Commit")
notes.where(:noteable_id => commit.id, :noteable_type => "Commit", :line_code => nil)
end
def commit_line_notes(commit)
notes.where(:noteable_id => commit.id, :noteable_type => "Commit").where("line_code not null")
end
def has_commits?