From 747dc30cd0758883e9edec3dee232e337e3be39f Mon Sep 17 00:00:00 2001 From: echarp Date: Sun, 5 Jan 2014 18:48:32 +0100 Subject: [PATCH] =?UTF-8?q?L'=C3=A9cran=20des=20statistiques=20est=20maint?= =?UTF-8?q?enant=20en=20place?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/stylesheets/list.css.sass | 2 ++ app/assets/stylesheets/region.css.sass | 7 +++++ app/controllers/regions_controller.rb | 13 ++++++++ app/views/layouts/application.html.haml | 2 +- app/views/regions/stats.html.haml | 42 +++++++++++++++++++++++++ config/locales/en.yml | 3 ++ config/locales/fr.yml | 10 ++++++ config/routes.rb | 1 + 8 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 app/assets/stylesheets/region.css.sass create mode 100644 app/views/regions/stats.html.haml diff --git a/app/assets/stylesheets/list.css.sass b/app/assets/stylesheets/list.css.sass index 9480abbb..b4371dcb 100644 --- a/app/assets/stylesheets/list.css.sass +++ b/app/assets/stylesheets/list.css.sass @@ -15,6 +15,8 @@ table.list background-color: #C9E2F5 td padding: 0.2em + &.quantity + text-align: right .view_link:link, .edit_link:link, .delete_link:link font-size: 0 diff --git a/app/assets/stylesheets/region.css.sass b/app/assets/stylesheets/region.css.sass new file mode 100644 index 00000000..36873836 --- /dev/null +++ b/app/assets/stylesheets/region.css.sass @@ -0,0 +1,7 @@ +.regions + table.stats + margin: 1em 0 + min-width: 60% + text-align: left + td.item + width: 90% diff --git a/app/controllers/regions_controller.rb b/app/controllers/regions_controller.rb index 61df8756..e9050bdc 100644 --- a/app/controllers/regions_controller.rb +++ b/app/controllers/regions_controller.rb @@ -2,4 +2,17 @@ class RegionsController < InheritedResources::Base def icallist @regions = Region.all end + + def stats + @regions = Region.all + + @events = Event.group(:city).having('count(city) > 3').order('count(city) desc').count(:city) + + @months = Event + .select('extract(year from start_time)') + .select('extract(month from start_time)') + .group('extract(year from start_time)') + .group('extract(month from start_time)') + .count() + end end diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index b4e7415d..6a2ea299 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -64,6 +64,6 @@ = link_to t('.map'), users_url = link_to t('.tags'), users_url = link_to t('.infos'), users_url - = link_to t('.stats'), users_url + = link_to t('.stats'), stats_regions_url = link_to t('.contact'), users_url = link_to t('.moderation'), users_url diff --git a/app/views/regions/stats.html.haml b/app/views/regions/stats.html.haml new file mode 100644 index 00000000..6ede87a6 --- /dev/null +++ b/app/views/regions/stats.html.haml @@ -0,0 +1,42 @@ +%h2=t '.title' + +%h3=t '.general' + +%table.list.stats + %tr + %td.item=t '.all' + %td.quantity= Event.count() + %tr + %td.item=t '.allModeration' + %td.quantity= Event.unscoped.where(moderated: 0).count() + +%h3=t '.regional' + +%table.list.stats + - @regions.each do |region| + %tr + %td.item= region.name + %td.quantity= Event.where(region: region).count() + +%h3=t '.city' + +%p Seules les villes où plus de trois évènements ont été organisés sont mentionnées. + +%table.list.stats + - @events.each do |event| + %tr + %td.item= event[0] + %td.quantity= event[1] + +%h3=t '.dates' + +%table.list.stats + - @months.each do |month| + %tr + %td.item= l(Date.new(month[0][0], month[0][1]), format: :month).capitalize + %td.quantity= month[1] + +%h3=t '.web' + +:markdown + Des statistiques Web générées par Webalizer [sont disponibles](http://agendadulibre.org/stats/). Elles sont protégées par le login *stats*, mot de passe *Cuntipshaf6* pour éviter le *spam de referers*. diff --git a/config/locales/en.yml b/config/locales/en.yml index 436e4639..287dc75d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -44,6 +44,9 @@ en: password: Password lastname: Name firstname: First name + date: + formats: + month: "%B %Y" time: formats: at: "%A %d %B %Y at %Hh%M" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 65911a3f..a78fd1ea 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -72,6 +72,7 @@ fr: - Samedi formats: long: "%A %d %B %Y" + month: "%B %Y" time: formats: at: "%A %d %B %Y à %Hh%M" @@ -110,3 +111,12 @@ fr: title: Liste des flux RSS icallist: title: Liste des calendriers iCal + stats: + title: Statistiques + general: Statistiques générales + all: Nombre d'évènements validés depuis la création de l'Agenda + allModeration: Nombre d'évènements en cours de modération + regional: Statistiques par région + city: Statistiques par ville + dates: Statistiques par date + web: Statistiques Web diff --git a/config/routes.rb b/config/routes.rb index dc884bec..f6ef7d04 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,7 @@ AgendaDuLibreRails::Application.routes.draw do resources :regions, only: [ :index ] do get 'icallist', on: :collection + get 'stats', on: :collection end resources :events resources :users