Add statistiques API for dashboard

This commit is contained in:
Xavier J 2016-02-29 15:15:44 +01:00
parent 3e62dd01fb
commit 9c1268fdd5
4 changed files with 36 additions and 0 deletions

View file

@ -0,0 +1,19 @@
class API::StatistiquesController < ApplicationController
def dossiers_stats
render json: {
total: total_dossiers,
mois: dossiers_mois
}
end
private
def total_dossiers
Dossier.all.size
end
def dossiers_mois
Dossier.where(created_at: (1.month.ago)..Time.now).size
end
end