13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'app/controllers/testimonials/nps_responses_controller.rb', line 13
def index
scope = NpsResponse.for_tenant(current_tenant)
@score = NpsResponse.score(scope)
@total = scope.count
@promoters = scope.where(score: 9..10).count
@passives = scope.where(score: 7..8).count
@detractors = scope.where(score: 0..6).count
@page = [params[:page].to_i, 1].max
@responses = scope.newest_first.offset((@page - 1) * PER_PAGE).limit(PER_PAGE + 1).to_a
@more = @responses.size > PER_PAGE
@responses = @responses.first(PER_PAGE)
@selected_response = scope.find_by(id: params[:response_id]) if params[:response_id].present?
end
|