discourse/app/controllers/admin/search_logs_controller.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
790 B
Ruby
Raw Permalink Normal View History

# frozen_string_literal: true
class Admin::SearchLogsController < Admin::StaffController
2017-11-14 18:13:50 -06:00
def index
period = params[:period] || "all"
search_type = params[:search_type] || "all"
render_serialized(SearchLog.trending(period&.to_sym, search_type&.to_sym), SearchLogsSerializer)
2017-11-14 18:13:50 -06:00
end
def term
params.require(:term)
term = params[:term]
period = params[:period] || "quarterly"
search_type = params[:search_type] || "all"
details = SearchLog.term_details(term, period&.to_sym, search_type&.to_sym)
raise Discourse::NotFound if details.blank?
2018-01-17 01:27:33 -06:00
result = Search.execute(params[:term], guardian: guardian)
details[:search_result] = serialize_data(result, GroupedSearchResultSerializer, result: result)
render_json_dump(term: details)
end
2017-11-14 18:13:50 -06:00
end