Skip to content

A platform for community discussion. Free, open, simple.

Revert "PERF: Query for email was not using index."

Guo Xiang Tanc85e1fdb5055
diff --git a/app/models/user.rb b/app/models/user.rb
index 6ae9ef16c23..0ac14d77a19 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -134,9 +134,7 @@ class User < ActiveRecord::Base
# set to true to optimize creation and save for imports
attr_accessor :import_mode
- scope :with_email, ->(email) do
- joins(:user_emails).where("lower(user_emails.email)::text = ?", email)
- end
+ scope :with_email, ->(email) { joins(:user_emails).where(user_emails: { email: email }) }
scope :human_users, -> { where('users.id > 0') }