2014-08-06 14:47:47 +02:00
|
|
|
# Manage regions, mostly get stats out of them
|
2014-01-02 00:21:49 +01:00
|
|
|
class RegionsController < InheritedResources::Base
|
2014-01-05 18:48:32 +01:00
|
|
|
def stats
|
2014-07-01 15:50:39 +02:00
|
|
|
@region_events = Event.joins(:related_region).group(:name).count(:name)
|
2014-01-05 18:48:32 +01:00
|
|
|
|
2014-08-06 14:47:47 +02:00
|
|
|
@city_events = Event.group(:city).having('count(city) > 3')
|
|
|
|
.order('count(city) desc').count :city
|
2014-01-05 18:48:32 +01:00
|
|
|
|
2014-07-26 18:41:37 +02:00
|
|
|
# Used in sqlite
|
2014-08-06 14:47:47 +02:00
|
|
|
# .group('strftime("%Y", start_time)')
|
|
|
|
# .group('strftime("%m", start_time)')
|
2014-05-10 12:06:34 +02:00
|
|
|
@month_events = Event
|
2014-07-26 18:41:37 +02:00
|
|
|
.group('extract(year from start_time)')
|
|
|
|
.group('extract(month from start_time)')
|
2014-08-06 14:47:47 +02:00
|
|
|
.count
|
2014-01-05 18:48:32 +01:00
|
|
|
end
|
2014-01-02 00:21:49 +01:00
|
|
|
end
|