Sha256: a79ac7726e6d7f9cccf9c696df69fc181f32fdc29a23b715271203b9099e3bd0
Contents?: true
Size: 1.3 KB
Versions: 19
Compression:
Stored size: 1.3 KB
Contents
class SearchController < ApplicationController def mentions q = params[:query] delimiter = params[:delimiter] search_group = "spaces,pages,projects,bugs,tasks,stories,users,attachments" if delimiter == "!" search_group = "attachments" end query = Tire.search(search_group) do query do boolean do should { string "title:#{q}*" } should { string "filename:#{q}*" } should { string "name:#{q}*" } should { string "email:#{q}*" } end end end render json: query.results.map{|result| process_result(result) } end protected #TODO: dirty. fix. def process_result(result) json = {} json[:type] = result._type if ["space", "page"].include?(result._type) json[:name] = result.title json[:url] = wiki_page_url(result.id) json[:space] = result.load.root.title elsif ["project", "bug", "task", "story"].include?(result._type) json[:name] = result.title json[:url] = ticket_url(result.id) json[:project] = result.load.root.title elsif result._type == "attachment" json[:name] = result.filename json[:url] = attachment_url(result.id) elsif result._type == "user" json[:name] = result.name json[:email] = result.email end json end end
Version data entries
19 entries across 19 versions & 1 rubygems