FIX: user summary's "most liked by" query
This commit is contained in:
parent
2db42e970d
commit
ae4dd6e679
|
@ -52,7 +52,12 @@ class UserSummary
|
||||||
def most_liked_by_users
|
def most_liked_by_users
|
||||||
likers_ids = []
|
likers_ids = []
|
||||||
counts = []
|
counts = []
|
||||||
UserAction.where(user: @user)
|
UserAction.joins("JOIN posts ON posts.id = user_actions.target_post_id")
|
||||||
|
.joins("JOIN topics ON topics.id = posts.topic_id")
|
||||||
|
.where("posts.deleted_at IS NULL")
|
||||||
|
.where("topics.deleted_at IS NULL")
|
||||||
|
.where("topics.archetype <> '#{Archetype.private_message}'")
|
||||||
|
.where(user: @user)
|
||||||
.where(action_type: UserAction::WAS_LIKED)
|
.where(action_type: UserAction::WAS_LIKED)
|
||||||
.group(:acting_user_id)
|
.group(:acting_user_id)
|
||||||
.order("COUNT(*) DESC")
|
.order("COUNT(*) DESC")
|
||||||
|
|
Loading…
Reference in New Issue