You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/models/searchable/course.rb

38 lines
718 B

module Searchable::Course
extend ActiveSupport::Concern
included do
searchkick language: 'chinese', callbacks: :async
scope :search_import, -> { includes(:teacher_users, teacher: { user_extension: :school } ) }
end
def searchable_title
name
end
def search_data
{
name: name,
author_name: teacher&.real_name
}
end
def to_searchable_json
{
id: id,
author_name: teacher.real_name,
author_school_name: teacher.school_name,
visits_count: visits,
members_count: members_count,
is_public: is_public == 1
}
end
module ClassMethods
def searchable_includes
{ teacher: { user_extension: :school } }
end
end
end