eBooru/app/controllers/post_favorites_controller.rb
Earlopain fc7d84affd
[RuboCop] Enable Style/FrozenStringLiteralComment
This reduces allocations on the posts page by about 5%, from basic testing
2024-02-25 18:15:55 +01:00

17 lines
605 B
Ruby

# frozen_string_literal: true
class PostFavoritesController < ApplicationController
respond_to :html
def index
@post = Post.find(params[:post_id])
query = User.includes(:user_status).joins(:favorites)
unless CurrentUser.is_moderator?
query = query.where("bit_prefs & :value != :value", { value: User.flag_value_for("enable_privacy_mode") }).or(query.where(favorites: { user_id: CurrentUser.id }))
end
query = query.where(favorites: { post_id: @post.id })
query = query.order("users.name asc")
@users = query.paginate(params[:page], limit: params[:limit])
end
end