Les stats par région sont ordonnancées par le nombre d'evts

This commit is contained in:
echarp 2014-10-21 00:35:43 +02:00
parent 604bbbb443
commit 0f8c638f9d
3 changed files with 9 additions and 6 deletions

View File

@ -1,7 +1,8 @@
# Manage regions, mostly get stats out of them
class RegionsController < InheritedResources::Base
def stats
@region_events = Event.joins(:related_region).group(:name).count(:name)
@region_events = Event.joins(:related_region).group(:name)
.order('count(name) desc').count :name
@city_events = Event.group(:city).having('count(city) > 3')
.order('count(city) desc').count :city
@ -9,8 +10,7 @@ class RegionsController < InheritedResources::Base
# Used in sqlite
# .group('strftime("%Y", start_time)')
@year_events = Event
.group('extract(year from start_time)')
.count
.group('extract(year from start_time)').count
# Used in sqlite
# .group('strftime("%Y", start_time)')

View File

@ -1,6 +1,7 @@
# This is mostly to group events around a region
class Region < ActiveRecord::Base
has_many :lugs, foreign_key: :region
has_many :events, foreign_key: :region
default_scope { order :name }

View File

@ -4,10 +4,10 @@
%dl
%dt=t '.all'
%dd.quantity= number_with_delimiter Event.count()
%dd.quantity= number_with_delimiter Event.count
%dt=t '.allModeration'
%dd.quantity= number_with_delimiter Event.unscoped.where(moderated: 0).count()
%dd.quantity= number_with_delimiter Event.unscoped.where(moderated: 0).count
%h3
%em.fa.fa-calendar
@ -45,7 +45,9 @@
%dl
- @region_events.each do |region|
%dt.item= region[0]
%dt.item
= link_to root_url region: Region.find_by_name(region[0]).id do
= region[0]
%dd.quantity= number_with_delimiter region[1]
%h3=t '.city'