feat: Search contacts using phone number (#1440)

This commit is contained in:
Vishal Pandey 2020-11-23 11:00:07 +05:30 committed by GitHub
parent 4fe29fefb4
commit 942d1fd0af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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