From ec6f14df0ce68192b9815a3895d1cc2737f23b6b Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 12 Nov 2012 09:39:44 +0000 Subject: [PATCH] Use counter caches to improve spam scoring Now that we have the counter caches we can take all edits and traces into account without incurring the cost of having to scan the database to count them all. --- app/models/user.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 3b43130fa..6ea4de9be 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -207,8 +207,8 @@ class User < ActiveRecord::Base ## # return a spam score for a user def spam_score - changeset_score = self.changesets.limit(10).length * 50 - trace_score = self.traces.limit(10).length * 50 + changeset_score = self.changesets.size * 50 + trace_score = self.traces.size * 50 diary_entry_score = self.diary_entries.inject(0) { |s,e| s += e.body.spam_score } diary_comment_score = self.diary_comments.inject(0) { |s,c| s += c.body.spam_score } -- 2.39.5