2017-11-15 08:13:50 +08:00
|
|
|
class Admin::SearchLogsController < Admin::AdminController
|
|
|
|
|
|
|
|
def index
|
|
|
|
period = params[:period] || "all"
|
2017-11-29 01:54:27 +08:00
|
|
|
search_type = params[:search_type] || "all"
|
|
|
|
render_serialized(SearchLog.trending(period&.to_sym, search_type&.to_sym), SearchLogsSerializer)
|
2017-11-15 08:13:50 +08:00
|
|
|
end
|
|
|
|
|
2017-12-20 10:41:31 +08:00
|
|
|
def term
|
|
|
|
params.require(:term)
|
|
|
|
|
|
|
|
term = params[:term]
|
|
|
|
period = params[:period] || "yearly"
|
|
|
|
search_type = params[:search_type] || "all"
|
|
|
|
|
|
|
|
details = SearchLog.term_details(term, period&.to_sym, search_type&.to_sym)
|
|
|
|
raise Discourse::NotFound if details.blank?
|
|
|
|
|
|
|
|
render_json_dump(term: details)
|
|
|
|
end
|
|
|
|
|
2017-11-15 08:13:50 +08:00
|
|
|
end
|