mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: Don't select columns if we don't have to.
This commit is contained in:
parent
803f5d85ee
commit
479ca86713
2 changed files with 18 additions and 22 deletions
|
@ -28,25 +28,9 @@ class PostActionsController < ApplicationController
|
|||
def users
|
||||
guardian.ensure_can_see_post_actors!(@post.topic, @post_action_type_id)
|
||||
|
||||
users = User.select(['null as post_url',
|
||||
'users.id',
|
||||
'users.username',
|
||||
'users.username_lower',
|
||||
'users.email',
|
||||
'users.use_uploaded_avatar',
|
||||
'users.uploaded_avatar_id',
|
||||
'users.uploaded_avatar_template',
|
||||
'post_actions.related_post_id'])
|
||||
.joins(:post_actions)
|
||||
.where(['post_actions.post_id = ? and post_actions.post_action_type_id = ? and post_actions.deleted_at IS NULL', @post.id, @post_action_type_id])
|
||||
.to_a
|
||||
post_actions = @post.post_actions.where(post_action_type_id: @post_action_type_id).includes(:user)
|
||||
|
||||
urls = Post.urls(users.map{|u| u.related_post_id})
|
||||
users.each do |u|
|
||||
u.post_url = urls[u.related_post_id.to_i]
|
||||
end
|
||||
|
||||
render_serialized(users, PostActionUserSerializer)
|
||||
render_serialized(post_actions.to_a, PostActionUserSerializer)
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
|
|
@ -1,8 +1,20 @@
|
|||
class PostActionUserSerializer < BasicUserSerializer
|
||||
attributes :post_url
|
||||
attributes :id, :username, :avatar_template, :post_url
|
||||
|
||||
# reserved
|
||||
def post_url
|
||||
object.post_url
|
||||
def id
|
||||
object.user.id
|
||||
end
|
||||
|
||||
def username
|
||||
object.user.username
|
||||
end
|
||||
|
||||
def avatar_template
|
||||
object.user.avatar_template
|
||||
end
|
||||
|
||||
def post_url
|
||||
object.related_post_id
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue