-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathquestions_controller.rb
More file actions
41 lines (37 loc) · 1.16 KB
/
questions_controller.rb
File metadata and controls
41 lines (37 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
class Admin::QuestionsController < Admin::BaseController
def index
@filter = Admin::Filters::QuestionsFilter.new(filter_params)
render :index, status: :unprocessable_content if @filter.errors.present?
end
def show
question_scope = Question.includes(
conversation: :signon_user,
answer: [{ sources: :chunk }, :feedback, :topics, { answer_relevancy_aggregate: :runs }],
)
@question = question_scope.find(params[:id])
@answer = @question.answer
@question_number = Question.where(conversation: @question.conversation)
.where("created_at <= ? ", @question.created_at)
.count
@total_questions = Question.where(conversation: @question.conversation).count
end
private
def filter_params
params.permit(
:search,
:status,
:source,
{ start_date_params: %i[day month year], end_date_params: %i[day month year] },
:answer_feedback_useful,
:question_routing_label,
:page,
:sort,
:signon_user_id,
:conversation_id,
:end_user_id,
:primary_topic,
:secondary_topic,
:completeness,
)
end
end