From 4658e18db5fe8e90e8ad7f53ed52fe31009a713a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sun, 11 Oct 2020 20:47:51 +0200 Subject: [PATCH] Re-add and apply Rails/UniqBeforePluck rule We removed it in commit d639cd58 because it recommended using `uniq` where `distinct` was more appropriate. This has been fixed in rubocop-rails 2.6.0. --- .rubocop.yml | 3 +++ app/controllers/admin/stats_controller.rb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 8f9cbdaa0..c3ebd2b40 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -300,6 +300,9 @@ Rails/SkipsModelValidations: Rails/TimeZone: Enabled: true +Rails/UniqBeforePluck: + Enabled: true + Rails/UniqueValidationWithoutIndex: Enabled: true Severity: refactor diff --git a/app/controllers/admin/stats_controller.rb b/app/controllers/admin/stats_controller.rb index b7c6c6cad..14a32c17e 100644 --- a/app/controllers/admin/stats_controller.rb +++ b/app/controllers/admin/stats_controller.rb @@ -1,6 +1,6 @@ class Admin::StatsController < Admin::BaseController def show - @event_types = Ahoy::Event.pluck(:name).uniq.sort + @event_types = Ahoy::Event.distinct.order(:name).pluck(:name) @visits = Visit.count @debates = Debate.with_hidden.count