* Converts queries to use active record instead of raw sql. This ensures that user objects are loaded by rails in the join, so that we don't have to issue `User.find` calls to load users one-by-one. * Use `.includes` to preload associations used in the view, to avoid additional N+1 query problems (primarily, calls to link_to_user also causing users to be loaded one-by-one).
12 lines
209 B
Ruby
12 lines
209 B
Ruby
module Moderator
|
|
module Dashboard
|
|
module Queries
|
|
class UserFeedback
|
|
def self.all
|
|
::UserFeedback.includes(:user).order("id desc").limit(10)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|