json.shixuns_count @results.total_count json.shixun_list do json.array! @results.with_highlights(multiple: true) do |obj, highlights| json.merge! obj.to_searchable_json json.challenge_names obj.challenges.pluck(:subject) highlights[:description]&.first&.sub!(@reg, '') highlights[:description]&.map{|des| des.gsub(@atta_reg, '')} highlights[:content]&.first&.sub!(@reg, '') highlights[:content]&.map{|des| des.gsub(@atta_reg, '')} json.title highlights.delete(:name)&.join('...') || obj.searchable_title json.description highlights[:description]&.join('...') || Util.extract_content(obj.description)[0..300]&.gsub(@atta_reg, '') json.pic url_to_avatar(obj) json.content highlights json.level level_to_s(obj.trainee) #if params[:sort] != "wechat_myshixuns_count" json.subjects obj.subjects.select{ |s| s.status == 2 && s.hidden == 0} do |subject| json.(subject, :id, :name) end #end end end