chore: Ingore case while searching contact name, email (#1505)

This commit is contained in:
Pranav Raj S
2020-12-11 23:25:00 +05:30
committed by GitHub
parent b6ca77158c
commit 1ade4f75ea
3 changed files with 29 additions and 4 deletions

View File

@@ -14,7 +14,10 @@ class Api::V1::Accounts::ContactsController < Api::V1::Accounts::BaseController
def search
render json: { error: 'Specify search string with parameter q' }, status: :unprocessable_entity if params[:q].blank? && return
contacts = resolved_contacts.where('name LIKE :search OR email LIKE :search OR phone_number LIKE :search', search: "%#{params[:q]}%")
contacts = resolved_contacts.where(
'name ILIKE :search OR email ILIKE :search OR phone_number ILIKE :search',
search: "%#{params[:q]}%"
)
@contacts_count = contacts.count
@contacts = fetch_contact_last_seen_at(contacts)
end