Skip to content

Commit

Permalink
Use counter caches to improve spam scoring
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tomhughes committed Nov 12, 2012
1 parent 4cf82d1 commit ec6f14d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ def delete
##
# 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 }

Expand Down

0 comments on commit ec6f14d

Please sign in to comment.