]> git.openstreetmap.org Git - rails.git/commitdiff
Only count reports from distinct users in spam checks
authorTom Hughes <tom@compton.nu>
Sun, 16 Feb 2025 14:06:46 +0000 (14:06 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 16 Feb 2025 14:08:22 +0000 (14:08 +0000)
app/models/user.rb

index 21fe2181b20abe9bfce7b196699d6fc368aca722..8d061e26bb626cd7c1a42fe9d6c6fb8e72e044fe 100644 (file)
@@ -359,7 +359,7 @@ class User < ApplicationRecord
     trace_score = traces.size * 50
     diary_entry_score = diary_entries.visible.inject(0) { |acc, elem| acc + elem.body.spam_score }
     diary_comment_score = diary_comments.visible.inject(0) { |acc, elem| acc + elem.body.spam_score }
     trace_score = traces.size * 50
     diary_entry_score = diary_entries.visible.inject(0) { |acc, elem| acc + elem.body.spam_score }
     diary_comment_score = diary_comments.visible.inject(0) { |acc, elem| acc + elem.body.spam_score }
-    report_score = Report.where(:category => "spam", :issue => issues.with_status("open")).count * 20
+    report_score = Report.where(:category => "spam", :issue => issues.with_status("open")).distinct.count(:user_id) * 20
 
     score = description.spam_score / 4.0
     score += diary_entries.visible.where("created_at > ?", 1.day.ago).count * 10
 
     score = description.spam_score / 4.0
     score += diary_entries.visible.where("created_at > ?", 1.day.ago).count * 10