Class: Testimonials::Api::StatsController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- Testimonials::ApplicationController
- BaseController
- Testimonials::Api::StatsController
- Defined in:
- app/controllers/testimonials/api/stats_controller.rb
Overview
Powers rating badges: "★ 4.9 from 87 reviews".
Instance Method Summary collapse
Instance Method Details
#show ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/testimonials/api/stats_controller.rb', line 7 def show scope = Testimonial.for_tenant(current_tenant).publishable rated = scope.where.not(rating: nil) render json: { count: scope.count, average_rating: rated.average(:rating)&.to_f&.round(2), ratings_count: rated.count, nps_score: (NpsResponse.score(NpsResponse.for_tenant(current_tenant)) if Testimonials.config.nps) } end |