Statistiques par région et année
This commit is contained in:
parent
4c6f0908af
commit
d9b69aff05
@ -7,12 +7,14 @@ $(document).ready ->
|
|||||||
|
|
||||||
$(this).find('.sparkline').sparkline vals, width: '5em'
|
$(this).find('.sparkline').sparkline vals, width: '5em'
|
||||||
|
|
||||||
vals = $('table.list.dates tfoot th.quantity').map ->
|
|
||||||
|
$('table.list.dates tfoot').each ->
|
||||||
|
vals = $(this).find('th.quantity').map ->
|
||||||
return parseInt $(this).html().replace(' ', '')
|
return parseInt $(this).html().replace(' ', '')
|
||||||
|
|
||||||
$('tfoot .sparkline').sparkline vals,
|
$(this).find('.sparkline').sparkline vals,
|
||||||
type: 'bar'
|
type: 'bar'
|
||||||
height: '3em'
|
height: '3em'
|
||||||
barWidth: '80em'
|
barWidth: '100%'
|
||||||
barColor: '#9CC5EE'
|
barColor: '#9CC5EE'
|
||||||
barSpacing: 2
|
barSpacing: 2
|
||||||
|
@ -5,13 +5,12 @@ class StatsController < ApplicationController
|
|||||||
private
|
private
|
||||||
|
|
||||||
def set_temporal
|
def set_temporal
|
||||||
@year_events = Event.group(year_grouping).count
|
@years = Event.group(year_grouping).count
|
||||||
@month_events = Event.group(year_grouping, month_grouping).count
|
@months = Event.group(year_grouping, month_grouping).count
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_local
|
def set_local
|
||||||
@region_events = Event.joins(:related_region).group(:name)
|
@regions = Event.joins(:related_region).group(:region, year_grouping).count
|
||||||
.order('count(name) desc').count
|
|
||||||
@city_events = Event.group(:city).having('count(city) > 3')
|
@city_events = Event.group(:city).having('count(city) > 3')
|
||||||
.order('count(city) desc').count
|
.order('count(city) desc').count
|
||||||
end
|
end
|
||||||
|
@ -17,15 +17,15 @@
|
|||||||
%thead
|
%thead
|
||||||
%tr
|
%tr
|
||||||
%th/
|
%th/
|
||||||
- @year_events.each do |year|
|
- @years.each do |year|
|
||||||
%th= year[0]
|
%th= year[0]
|
||||||
%tbody
|
%tbody
|
||||||
- (1..12).each do |m|
|
- (1..12).each do |m|
|
||||||
%tr
|
%tr
|
||||||
%th.month= I18n.t('date.month_names')[m]
|
%th.month= I18n.t('date.month_names')[m]
|
||||||
- @year_events.each do |year|
|
- @years.each do |year|
|
||||||
%td.quantity
|
%td.quantity
|
||||||
- line = @month_events.find { |line| line[0][0] == year[0] && line[0][1].try(:to_i) == m }
|
- line = @months.find { |line| line[0][0] == year[0] && line[0][1].try(:to_i) == m }
|
||||||
= link_to root_path(start_date: "#{year[0]}-#{m}-01") do
|
= link_to root_path(start_date: "#{year[0]}-#{m}-01") do
|
||||||
= number_with_delimiter line[1] if line
|
= number_with_delimiter line[1] if line
|
||||||
%td.sparkline/
|
%td.sparkline/
|
||||||
@ -33,23 +33,32 @@
|
|||||||
%tfoot
|
%tfoot
|
||||||
%tr
|
%tr
|
||||||
%th=t '.total'
|
%th=t '.total'
|
||||||
- @year_events.each do |year|
|
- @years.each do |year|
|
||||||
%th.quantity= number_with_delimiter year[1]
|
%th.quantity= number_with_delimiter year[1]
|
||||||
|
|
||||||
%tr
|
%tr
|
||||||
%th/
|
%th/
|
||||||
%td.sparkline(colspan="#{@year_events.size}")/
|
%td.sparkline(colspan="#{@years.size}")/
|
||||||
|
|
||||||
%h3
|
%h3
|
||||||
%em.fa.fa-shield
|
%em.fa.fa-shield
|
||||||
=t '.regional'
|
=t '.regional'
|
||||||
|
|
||||||
%dl
|
%table.list.dates
|
||||||
- @region_events.each do |region|
|
%thead
|
||||||
%dt.item
|
%tr
|
||||||
= link_to root_path region: Region.find_by_name(region[0]).id do
|
%th/
|
||||||
= region[0]
|
- @years.each do |year|
|
||||||
%dd.quantity= number_with_delimiter region[1]
|
%th= year[0]
|
||||||
|
%tbody
|
||||||
|
- Region.all.each do |region|
|
||||||
|
%tr
|
||||||
|
%th.month= region
|
||||||
|
- @years.each do |year|
|
||||||
|
%td.quantity
|
||||||
|
= link_to root_path(year: "#{year[0]}", region: region.id) do
|
||||||
|
= number_with_delimiter @regions[[region.id, year[0]]]
|
||||||
|
%td.sparkline/
|
||||||
|
|
||||||
%h3=t '.city'
|
%h3=t '.city'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user