demarches-normaliennes/app/controllers/api/public/v1/stats_controller.rb
Sébastien Carceles 68ddae7382
feat(demarche): prefilling stats (#8436)
* force json content type for POST / PATCH / PUT

* add specs about stats dossiers funnel

* new endpoint to render stats about a procedure
2023-01-20 13:28:02 +00:00

20 lines
702 B
Ruby

class API::Public::V1::StatsController < API::Public::V1::BaseController
before_action :retrieve_procedure
def index
render json: {
funnel: @procedure.stats_dossiers_funnel.as_json,
processed: @procedure.stats_termines_states.as_json,
processed_by_week: @procedure.stats_termines_by_week.as_json,
processing_time: @procedure.stats_usual_traitement_time.as_json,
processing_time_by_month: @procedure.stats_usual_traitement_time_by_month_in_days.as_json
}
end
private
def retrieve_procedure
@procedure = Procedure.publiees_ou_brouillons.opendata.find_by(id: params[:id])
render_not_found("procedure", params[:id]) if @procedure.blank?
end
end