mirror of
https://github.com/discourse/discourse.git
synced 2025-04-02 06:50:19 +08:00
change count>0 to exists
This commit is contained in:
parent
868c489d5e
commit
8124f26a6e
app
controllers
models
serializers
@ -26,7 +26,7 @@ class DirectoryItemsController < ApplicationController
|
|||||||
user_ids = UserSearch.new(params[:name]).search.pluck(:id)
|
user_ids = UserSearch.new(params[:name]).search.pluck(:id)
|
||||||
if user_ids.present?
|
if user_ids.present?
|
||||||
# Add the current user if we have at least one other match
|
# Add the current user if we have at least one other match
|
||||||
if current_user && result.dup.where(user_id: user_ids).count > 0
|
if current_user && result.dup.where(user_id: user_ids).exists?
|
||||||
user_ids << current_user.id
|
user_ids << current_user.id
|
||||||
end
|
end
|
||||||
result = result.where(user_id: user_ids)
|
result = result.where(user_id: user_ids)
|
||||||
|
@ -32,7 +32,7 @@ class PostAnalyzer
|
|||||||
|
|
||||||
cooked_stripped.css("img").reject do |t|
|
cooked_stripped.css("img").reject do |t|
|
||||||
if dom_class = t["class"]
|
if dom_class = t["class"]
|
||||||
(Post.white_listed_image_classes & dom_class.split).count > 0
|
(Post.white_listed_image_classes & dom_class.split).exists?
|
||||||
end
|
end
|
||||||
end.count
|
end.count
|
||||||
end
|
end
|
||||||
|
@ -243,7 +243,7 @@ class PostSerializer < BasicPostSerializer
|
|||||||
summary[:can_defer_flags] = true if scope.is_staff? &&
|
summary[:can_defer_flags] = true if scope.is_staff? &&
|
||||||
PostActionType.flag_types.values.include?(id) &&
|
PostActionType.flag_types.values.include?(id) &&
|
||||||
active_flags.present? && active_flags.has_key?(id) &&
|
active_flags.present? && active_flags.has_key?(id) &&
|
||||||
active_flags[id].count > 0
|
active_flags[id].exists?
|
||||||
end
|
end
|
||||||
|
|
||||||
if actions.present? && actions.has_key?(id)
|
if actions.present? && actions.has_key?(id)
|
||||||
|
@ -369,7 +369,7 @@ class UserSerializer < BasicUserSerializer
|
|||||||
end
|
end
|
||||||
|
|
||||||
def has_title_badges
|
def has_title_badges
|
||||||
object.badges.where(allow_title: true).count > 0
|
object.badges.where(allow_title: true).exists?
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_fields
|
def user_fields
|
||||||
|
Loading…
x
Reference in New Issue
Block a user