move vote similarity code into danbooru, add listing for super voters
This commit is contained in:
@@ -12,6 +12,18 @@ class PostVote < ActiveRecord::Base
|
||||
where("created_at < ?", 30.days.ago).delete_all
|
||||
end
|
||||
|
||||
def self.positive_user_ids
|
||||
select_values_sql("select user_id from post_votes where score > 0 group by user_id having count(*) > 100")
|
||||
end
|
||||
|
||||
def self.negative_post_ids(user_id)
|
||||
select_values_sql("select post_id from post_votes where score < 0 and user_id = ?", user_id)
|
||||
end
|
||||
|
||||
def self.positive_post_ids(user_id)
|
||||
select_values_sql("select post_id from post_votes where score > 0 and user_id = ?", user_id)
|
||||
end
|
||||
|
||||
def score=(x)
|
||||
if x == "up"
|
||||
Post.where(:id => post_id).update_all("score = score + #{magnitude}, up_score = up_score + #{magnitude}")
|
||||
|
||||
@@ -13,18 +13,11 @@ class SuperVoter < ActiveRecord::Base
|
||||
|
||||
def self.init!
|
||||
prune!
|
||||
report = Reports::UserSimilarity.new(User.admins.first.id)
|
||||
report.prime("post_vote_similarity")
|
||||
report = PostVoteSimilarity.new(User.admins.first.id)
|
||||
|
||||
report.result.scan(/\S+/).in_groups_of(2).each do |user_id, score|
|
||||
unless where("user_id = ?", user_id.to_i).exists?
|
||||
create(:user_id => user_id)
|
||||
end
|
||||
end
|
||||
|
||||
User.admins.each do |user|
|
||||
unless where("user_id = ?", user.id).exists?
|
||||
create(:user_id => user.id)
|
||||
report.calculate_positive.each do |element|
|
||||
unless where("user_id = ?", element.user_id).exists?
|
||||
create(:user_id => element.user_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user