application record: drop execute_sql, select_value_sql methods.
This commit is contained in:
@@ -11,16 +11,19 @@ class PostVote < ApplicationRecord
|
||||
after_create :update_post_on_create
|
||||
after_destroy :update_post_on_destroy
|
||||
|
||||
scope :positive, -> { where("post_votes.score > 0") }
|
||||
scope :negative, -> { where("post_votes.score < 0") }
|
||||
|
||||
def self.positive_user_ids
|
||||
select_values_sql("select user_id from post_votes where score > 0 group by user_id having count(*) > 100")
|
||||
positive.group(:user_id).having("count(*) > 100").pluck(:user_id)
|
||||
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)
|
||||
negative.where(user_id: user_id).pluck(:post_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)
|
||||
positive.where(user_id: user_id).pluck(:post_id)
|
||||
end
|
||||
|
||||
def self.visible(user = CurrentUser.user)
|
||||
|
||||
Reference in New Issue
Block a user