From d5dbc2062729911cef571900151139feba17456a Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Thu, 20 May 2021 21:45:08 +0200 Subject: [PATCH] suite --- app/controllers/admin/sheets_controller.rb | 30 +++++++++++----------- app/views/admin/sheets/stats.html.haml | 4 +-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/controllers/admin/sheets_controller.rb b/app/controllers/admin/sheets_controller.rb index 2d0e4c9..06def96 100644 --- a/app/controllers/admin/sheets_controller.rb +++ b/app/controllers/admin/sheets_controller.rb @@ -139,22 +139,22 @@ class Admin::SheetsController < ApplicationController @gift_years = { - :nbr_foyers => SheetYear.count(:conditions => ['year = ? AND gift_year = ? ',@year, true]), - :nbr_familles => SheetYear.count(:conditions => ['year = ? AND gift_year = ? AND join_type = ?',@year, true,2]), - :nbr_associations => SheetYear.count(:conditions => ['year = ? AND gift_year = ? AND join_type = ?',@year, true,3]), - :nbr_individuel => SheetYear.count(:conditions => ['year = ? AND gift_year = ? AND join_type = ?',@year, true,1]), - :nbr_benefactors => SheetYear.count(:conditions => ['year = ? AND gift_year = ? AND benefactor = ?',@year, true,true]) + :nbr_foyers => SheetYear.where('year = ? AND gift_year = ? ',@year, true).count(), + :nbr_familles => SheetYear.where('year = ? AND gift_year = ? AND join_type = ?',@year, true,2).count(), + :nbr_associations => SheetYear.where('year = ? AND gift_year = ? AND join_type = ?',@year, true,3).count(), + :nbr_individuel => SheetYear.where('year = ? AND gift_year = ? AND join_type = ?',@year, true,1).count(), + :nbr_benefactors => SheetYear.where('year = ? AND gift_year = ? AND benefactor = ?',@year, true,true).count() } @gift_years[:pouvoirs] = (@gift_years[:nbr_familles] + @gift_years[:nbr_associations])*2 + @gift_years[:nbr_individuel] @renewed_prev_year = { - :nbr_foyers => SheetYear.count(:conditions => ['year = ? AND paid_at < ? ',@year, @start_date]), - :nbr_familles => SheetYear.count(:conditions => ['year = ? AND paid_at < ? AND join_type = ?',@year, @start_date,2]), - :nbr_associations => SheetYear.count(:conditions => ['year = ? AND paid_at < ? AND join_type = ?',@year, @start_date,3]), - :nbr_individuel => SheetYear.count(:conditions => ['year = ? AND paid_at < ? AND join_type = ?',@year, @start_date,1]), - :nbr_benefactors => SheetYear.count(:conditions => ['year = ? AND paid_at < ? AND benefactor = ?',@year, @start_date,true]) + :nbr_foyers => SheetYear.where('year = ? AND paid_at < ? ',@year, @start_date).count(), + :nbr_familles => SheetYear.where('year = ? AND paid_at < ? AND join_type = ?',@year, @start_date,2).count(), + :nbr_associations => SheetYear.where('year = ? AND paid_at < ? AND join_type = ?',@year, @start_date,3).count(), + :nbr_individuel => SheetYear.where('year = ? AND paid_at < ? AND join_type = ?',@year, @start_date,1).count(), + :nbr_benefactors => SheetYear.where('year = ? AND paid_at < ? AND benefactor = ?',@year, @start_date,true).count() } @renewed_prev_year[:pouvoirs] = (@renewed_prev_year[:nbr_familles] + @renewed_prev_year[:nbr_associations])*2 + @renewed_prev_year[:nbr_individuel] @@ -179,11 +179,11 @@ class Admin::SheetsController < ApplicationController while month <= @end_date @months[month.month.to_s] = { :month => month.month, - :nbr_foyers => SheetYear.count(:conditions => ['year = ? AND paid_at >= ? and paid_at <= ? ',@year, month, month.end_of_month]), - :nbr_familles => SheetYear.count(:conditions => ['year = ? AND paid_at >= ? and paid_at <= ? AND join_type = ?',@year, month, month.end_of_month,2]), - :nbr_associations => SheetYear.count(:conditions => ['year = ? AND paid_at >= ? and paid_at <= ? AND join_type = ?',@year, month, month.end_of_month,3]), - :nbr_individuel => SheetYear.count(:conditions => ['year = ? AND paid_at >= ? and paid_at <= ? AND join_type = ?',@year, month, month.end_of_month,1]), - :nbr_benefactors => SheetYear.count(:conditions => ['year = ? AND paid_at >= ? and paid_at <= ? AND benefactor = ?',@year, month, month.end_of_month,true]) + :nbr_foyers => SheetYear.where('year = ? AND paid_at >= ? and paid_at <= ? ',@year, month, month.end_of_month).count(), + :nbr_familles => SheetYear.where('year = ? AND paid_at >= ? and paid_at <= ? AND join_type = ?',@year, month, month.end_of_month,2).count(), + :nbr_associations => SheetYear.where('year = ? AND paid_at >= ? and paid_at <= ? AND join_type = ?',@year, month, month.end_of_month,3).count(), + :nbr_individuel => SheetYear.where('year = ? AND paid_at >= ? and paid_at <= ? AND join_type = ?',@year, month, month.end_of_month,1).count(), + :nbr_benefactors => SheetYear.where('year = ? AND paid_at >= ? and paid_at <= ? AND benefactor = ?',@year, month, month.end_of_month,true).count() } diff --git a/app/views/admin/sheets/stats.html.haml b/app/views/admin/sheets/stats.html.haml index 36f33cd..c06929e 100644 --- a/app/views/admin/sheets/stats.html.haml +++ b/app/views/admin/sheets/stats.html.haml @@ -1,5 +1,5 @@ --last_year= SheetYear.find(:first, :order => "year DESC").year --first_year= SheetYear.find(:first, :order => "year ASC").year +-last_year= SheetYear.order("year DESC").first.year +-first_year= SheetYear.order("year ASC").first.year -y = last_year #stat_years