X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/5eb4c7c0d167f8a81d4b328c0ac4641ec2b61740..33799121b8a1ea5fdb1508ceda3fa99736db923f:/app/models/user.rb diff --git a/app/models/user.rb b/app/models/user.rb index 16f733c88..a63846e42 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -3,7 +3,7 @@ # Table name: users # # email :string not null -# id :bigint(8) not null, primary key +# id :bigint not null, primary key # pass_crypt :string not null # creation_time :datetime not null # display_name :string default(""), not null @@ -28,7 +28,7 @@ # diary_entries_count :integer default(0), not null # image_use_gravatar :boolean default(FALSE), not null # auth_provider :string -# home_tile :bigint(8) +# home_tile :bigint # tou_agreed :datetime # diary_comments_count :integer default(0) # note_comments_count :integer default(0) @@ -359,11 +359,13 @@ 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 } + 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 += diary_entry_score / diary_entries.visible.length unless diary_entries.visible.empty? score += diary_comment_score / diary_comments.visible.length unless diary_comments.visible.empty? + score += report_score score -= changeset_score score -= trace_score