[openstreetmap/openstreetmap-website] Add counts for notes and diary comments to user profiles (#1774)

Tom Hughes notifications at github.com
Thu Mar 1 21:23:46 UTC 2018

tomhughes commented on this pull request.

> @@ -25,7 +25,7 @@
 class NoteComment < ActiveRecord::Base
   belongs_to :note, :foreign_key => :note_id, :touch => true
-  belongs_to :author, :class_name => "User", :foreign_key => :author_id
+  belongs_to :author, :class_name => "User", :foreign_key => :author_id, :counter_cache => :notes_count

Are you sure it's counting the number of notes? I'm pretty sure that's going to count the total number of comments isn't it?

It's on the relationship between user and note comments, and the documentation explains:

> The counter cache is incremented when an object of this class is created and decremented when it's destroyed. 

So it will count every object of class `NoteComment` belonging to a given user.

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20180301/031c0ac4/attachment.html>

More information about the rails-dev mailing list