mirror of
https://github.com/discourse/discourse.git
synced 2024-12-14 10:23:40 +08:00
586454bcf1
* DEV: Add a dedicated Admin::StaffController base controller The current parent(Admin:AdminController) for all admin-related controllers uses a filter that allows only staff(admin, moderator) users. This refactor makes Admin::AdminController filter for only admins as the name suggests and introduces a base controller dedicated for staff-related endpoints. * DEV: Set staff-only controllers parent to Admin::StaffController Refactor staff-only controllers to inherit newly introduced Admin::StaffController abstract controller. This conveys the purpose of the parent controller better unlike the previously used parent controller.
27 lines
792 B
Ruby
27 lines
792 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Admin::SearchLogsController < Admin::StaffController
|
|
|
|
def index
|
|
period = params[:period] || "all"
|
|
search_type = params[:search_type] || "all"
|
|
render_serialized(SearchLog.trending(period&.to_sym, search_type&.to_sym), SearchLogsSerializer)
|
|
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?
|
|
|
|
result = Search.execute(params[:term], guardian: guardian)
|
|
details[:search_result] = serialize_data(result, GroupedSearchResultSerializer, result: result)
|
|
render_json_dump(term: details)
|
|
end
|
|
|
|
end
|