demarches-normaliennes/app/controllers/api/statistiques_controller.rb

20 lines
388 B
Ruby
Raw Normal View History

2016-02-29 15:15:44 +01:00
class API::StatistiquesController < ApplicationController
def dossiers_stats
render json: {
total: total_dossiers,
mois: dossiers_mois
}
end
private
def total_dossiers
2016-02-29 15:48:58 +01:00
Dossier.where.not(state: :draft).size
2016-02-29 15:15:44 +01:00
end
def dossiers_mois
2016-02-29 15:48:58 +01:00
Dossier.where.not(state: :draft).where(created_at: (1.month.ago)..Time.now).size
2016-02-29 15:15:44 +01:00
end
end