measures_controller.rb 554 B

1234567891011121314151617181920212223242526
  1. # frozen_string_literal: true
  2. class Api::V1::Admin::MeasuresController < Api::BaseController
  3. include Authorization
  4. before_action -> { authorize_if_got_token! :'admin:read' }
  5. before_action :set_measures
  6. after_action :verify_authorized
  7. def create
  8. authorize :dashboard, :index?
  9. render json: @measures, each_serializer: REST::Admin::MeasureSerializer
  10. end
  11. private
  12. def set_measures
  13. @measures = Admin::Metrics::Measure.retrieve(
  14. params[:keys],
  15. params[:start_at],
  16. params[:end_at],
  17. params
  18. )
  19. end
  20. end