Created
March 28, 2012 14:26
-
-
Save moskvin/2226604 to your computer and use it in GitHub Desktop.
Patch for gitlab postgres support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/models/issue.rb b/app/models/issue.rb | |
index ce4944a..9e446ad 100644 | |
--- a/app/models/issue.rb | |
+++ b/app/models/issue.rb | |
@@ -2,6 +2,7 @@ class Issue < ActiveRecord::Base | |
belongs_to :project | |
belongs_to :author, :class_name => "User" | |
belongs_to :assignee, :class_name => "User" | |
+# has_many :notes, :dependent => :destroy, :conditions => ["noteable_id = '?'", 6] | |
has_many :notes, :as => :noteable, :dependent => :destroy | |
attr_protected :author, :author_id, :project, :project_id | |
@@ -51,7 +52,23 @@ class Issue < ActiveRecord::Base | |
# Return the number of +1 comments (upvotes) | |
def upvotes | |
- notes.select(&:upvote?).size | |
+ # notes.select(&:upvote?).size | |
+ count = 0 | |
+ #notes = Note.find(:all, :conditions => ["noteable_id = '?'", self.id]) | |
+ notes = Note.where(noteable_id: self.id.to_s, noteable_type: 'Issue') | |
+ if notes | |
+ notes.each do |n| | |
+ if n.upvote? | |
+ count+=1 | |
+ end | |
+ end | |
+ end | |
+ count | |
+ end | |
+ | |
+ def notes | |
+ #Note.find(:all, :conditions => ["noteable_id = '?'", self.id]) | |
+ Note.where(noteable_id: self.id.to_s, noteable_type: 'Issue') | |
end | |
end | |
# == Schema Information |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment