move vote similarity code into danbooru, add listing for super voters

This commit is contained in:
r888888888
2016-09-19 16:43:15 -07:00
parent 6241a50c31
commit bf2246f895
7 changed files with 101 additions and 11 deletions

View File

@@ -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}")