Permalink
Browse files
FEATURE: new API to search for a user by email
- Loading branch information
|
@@ -114,6 +114,10 @@ def filter_by_user_with_bypass(filter) |
|
|
end |
|
|
|
|
|
def filter_by_search |
|
|
if params[:email].present? |
|
|
return @query.where('user_emails.email = ?', params[:email].downcase) |
|
|
end |
|
|
|
|
|
filter = params[:filter] |
|
|
if filter.present? |
|
|
filter.strip! |
|
|
|
@@ -188,6 +188,20 @@ def real_users_count(query) |
|
|
|
|
|
expect(query.to_sql.downcase).not_to include("ilike") |
|
|
end |
|
|
|
|
|
it "can correctly bypass expensive ilike query" do |
|
|
user = Fabricate(:user, email: 'sam2@Sam.com') |
|
|
|
|
|
query = AdminUserIndexQuery.new(email: 'Sam@sam.com').find_users_query |
|
|
expect(query.count).to eq(0) |
|
|
expect(query.to_sql.downcase).not_to include("ilike") |
|
|
|
|
|
query = AdminUserIndexQuery.new(email: 'Sam2@sam.com').find_users_query |
|
|
expect(query.first.id).to eq(user.id) |
|
|
expect(query.count).to eq(1) |
|
|
expect(query.to_sql.downcase).not_to include("ilike") |
|
|
|
|
|
end |
|
|
end |
|
|
|
|
|
context "by email fragment" do |
|
|
This comment has been minimized.
discoursebot repliedNov 9, 2017
This commit has been mentioned on Discourse Meta. There might be relevant details there:
https://meta.discourse.org/t/discourse-api-searching-users-by-email/23097/16
This comment has been minimized.
discoursebot repliedNov 9, 2017
This commit has been mentioned on Discourse Meta. There might be relevant details there:
https://meta.discourse.org/t/api-best-way-to-get-user-details-by-email/20806/10
This comment has been minimized.
discoursebot repliedNov 9, 2017
This commit has been mentioned on Discourse Meta. There might be relevant details there:
https://meta.discourse.org/t/use-the-api-to-find-a-username-based-on-an-email/45424/6