Filter all tutors information, subjects, categories, courses and students based on query params.
# File app/controllers/mobile_app_api/v1/search_controller.rb, line 17 def global_search tutors = Tutor.search(query: params[:query]).records students = Student.search(query: params[:query]).records tutors_with_tasks = Tutor.search(task: params[:query]).records tutors_with_subjects = Tutor.search(subject: params[:query]).records categories = Category.search(params).records subjects = Subject.search(params).records courses = Course.search(params).records render json: { status: 200, search_count: tutors.total_count + tutors_with_tasks.total_count + tutors_with_subjects.total_count + categories.total_count + subjects.total_count + courses.total_count + students.total_count, service_providers: (tutors.records + tutors_with_tasks.records + tutors_with_subjects.records).map(&:full_info), categories: categories.records, subjects: subjects.records, courses: courses.records, students: students.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 students according to search parameters.
# File app/controllers/mobile_app_api/v1/search_controller.rb, line 37 def search_students students = Student.search(query: params[:query]).records render json: { status: 200, search_count: students.total_count, students: students.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 tutors = Tutor.search(query: params[:query]).records render json: { status: 200, search_count: tutors.total_count, service_providers: tutors.records.map(&:full_info), category_subjects_courses: tutors.records.map(&:categories_subjects_courses)} end
Method to get courses according to search parameters.
# File app/controllers/mobile_app_api/v1/search_controller.rb, line 11 def search_courses courses = Course.search(query: params[:query]).records render json: { status: 200, search_count: courses.total_count, courses: courses.records } end
Method to get subjects according to search parameters.
# File app/controllers/mobile_app_api/v1/search_controller.rb, line 53 def search_subjects subjects = Subject.search(query: params[:query]).records render json: { status: 200, search_count: subjects.total_count, subjects: subjects.records } end