agenda-libre-ruby/app/controllers/regions_controller.rb

24 lines
695 B
Ruby
Raw Normal View History

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