Filter all fixxperts information, trades, categories, subtrades and customers based on query params.
# File app/controllers/mobile_app_api/v1/search_controller.rb, line 17 def global_search fixxperts = Fixxpert.search(query: params[:query]).records customers = Customer.search(query: params[:query]).records fixxperts_with_tasks = Fixxpert.search(task: params[:query]).records fixxperts_with_trades = Fixxpert.search(trade: params[:query]).records categories = Category.search(params).records trades = Trade.search(params).records subtrades = Subtrade.search(params).records render json: { status: 200, search_count: fixxperts.total_count + fixxperts_with_tasks.total_count + fixxperts_with_trades.total_count + categories.total_count + trades.total_count + subtrades.total_count + customers.total_count, service_providers: (fixxperts.records + fixxperts_with_tasks.records + fixxperts_with_trades.records).map(&:full_info), categories: categories.records, trades: trades.records, subtrades: subtrades.records, customers: customers.records.map(&:full_info) } end
Method to get categories according to search parameters.
# File app/controllers/mobile_app_api/v1/search_controller.rb, line 47 def search_categories categories = Category.search(query: params[:query]).records render json: { status: 200, search_count: categories.total_count, categories: categories.records } end
Method to get customers according to search parameters.
# File app/controllers/mobile_app_api/v1/search_controller.rb, line 37 def search_customers customers = Customer.search(query: params[:query]).records render json: { status: 200, search_count: customers.total_count, customers: customers.records.map(&:full_info) } end
Method to search all service providers.
# File app/controllers/mobile_app_api/v1/search_controller.rb, line 5 def search_service_providers fixxperts = Fixxpert.search(query: params[:query]).records render json: { status: 200, search_count: fixxperts.total_count, service_providers: fixxperts.records.map(&:full_info), category_trades_subtrades: fixxperts.records.map(&:categories_trades_subtrades)} end
Method to get subtrades according to search parameters.
# File app/controllers/mobile_app_api/v1/search_controller.rb, line 11 def search_subtrades subtrades = Subtrade.search(query: params[:query]).records render json: { status: 200, search_count: subtrades.total_count, subtrades: subtrades.records } end
Method to get trades according to search parameters.
# File app/controllers/mobile_app_api/v1/search_controller.rb, line 53 def search_trades trades = Trade.search(query: params[:query]).records render json: { status: 200, search_count: trades.total_count, trades: trades.records } end