From 5dda61ff08759e664f26c991d4daa594a06dc6c0 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 15 Nov 2024 16:01:14 -0500 Subject: [PATCH] Use `distinct` and `count` to generate query in `ReactionValidator` limit check --- app/validators/reaction_validator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/validators/reaction_validator.rb b/app/validators/reaction_validator.rb index 89d83de5a2..402fe3ae9e 100644 --- a/app/validators/reaction_validator.rb +++ b/app/validators/reaction_validator.rb @@ -23,6 +23,6 @@ class ReactionValidator < ActiveModel::Validator end def limit_reached?(reaction) - reaction.announcement.announcement_reactions.where.not(name: reaction.name).count('distinct name') >= LIMIT + reaction.announcement.announcement_reactions.where.not(name: reaction.name).distinct.count(:name) >= LIMIT end end