Meilleurs stats par dates, avec sparklines
This commit is contained in:
parent
d8492dbae7
commit
0fe4fa8eb5
4
Gemfile
4
Gemfile
@ -56,7 +56,7 @@ gem 'devise-i18n'
|
||||
gem 'rails-i18n'
|
||||
# Store some specific content, like application name and static pages contents
|
||||
gem 'i18n-active_record',
|
||||
git: 'git://github.com/svenfuchs/i18n-active_record.git',
|
||||
github: 'svenfuchs/i18n-active_record',
|
||||
require: 'i18n/active_record'
|
||||
gem 'http_accept_language'
|
||||
|
||||
@ -74,6 +74,8 @@ gem 'activeadmin', github: 'gregbell/active_admin'
|
||||
# A nicer markdown editor in active admin
|
||||
gem 'activeadmin_pagedown'
|
||||
|
||||
gem 'jquery-sparkline-rails', github: 'cubus/jquery-sparkline-rails'
|
||||
|
||||
# Markdown display
|
||||
gem 'redcarpet'
|
||||
|
||||
|
15
Gemfile.lock
15
Gemfile.lock
@ -1,3 +1,11 @@
|
||||
GIT
|
||||
remote: git://github.com/cubus/jquery-sparkline-rails.git
|
||||
revision: 5c2ced0fa68e5e099bec82b67bdf71f9d865da8a
|
||||
specs:
|
||||
jquery-sparkline-rails (2.1.1)
|
||||
jquery-rails
|
||||
rails (>= 3.2.2)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/gregbell/active_admin.git
|
||||
revision: 05778f4b7c8e821d584c7b4b08bcd79c02a0db76
|
||||
@ -87,7 +95,7 @@ GEM
|
||||
builder (3.2.2)
|
||||
celluloid (0.16.0)
|
||||
timers (~> 4.0.0)
|
||||
chunky_png (1.3.1)
|
||||
chunky_png (1.3.2)
|
||||
coderay (1.1.0)
|
||||
coffee-rails (4.1.0)
|
||||
coffee-script (>= 2.2.0)
|
||||
@ -176,7 +184,7 @@ GEM
|
||||
inherited_resources (1.4.1)
|
||||
has_scope (~> 0.6.0.rc)
|
||||
responders (~> 1.0.0.rc)
|
||||
jbuilder (2.2.2)
|
||||
jbuilder (2.2.3)
|
||||
activesupport (>= 3.0.0, < 5)
|
||||
multi_json (~> 1.2)
|
||||
jquery-rails (3.1.2)
|
||||
@ -185,7 +193,7 @@ GEM
|
||||
jquery-turbolinks (2.1.0)
|
||||
railties (>= 3.1.0)
|
||||
turbolinks
|
||||
jquery-ui-rails (5.0.1)
|
||||
jquery-ui-rails (5.0.2)
|
||||
railties (>= 3.2.16)
|
||||
json (1.8.1)
|
||||
kaminari (0.16.1)
|
||||
@ -376,6 +384,7 @@ DEPENDENCIES
|
||||
i18n-active_record!
|
||||
jbuilder (~> 2.0)
|
||||
jquery-rails
|
||||
jquery-sparkline-rails!
|
||||
jquery-turbolinks
|
||||
leaflet-rails
|
||||
meta-tags
|
||||
|
@ -12,6 +12,7 @@
|
||||
#
|
||||
#= require jquery
|
||||
#= require jquery_ujs
|
||||
#= require jquery.sparkline
|
||||
#= require jquery.turbolinks
|
||||
#= require turbolinks
|
||||
#= require tinymce-jquery
|
||||
|
17
app/assets/javascripts/regions.js.coffee
Normal file
17
app/assets/javascripts/regions.js.coffee
Normal file
@ -0,0 +1,17 @@
|
||||
$(document).ready ->
|
||||
$('table.list.dates tbody tr').each ->
|
||||
vals = $(this).find('td.quantity').map ->
|
||||
val = $(this).html().replace(' ', '').trim()
|
||||
if (val != '')
|
||||
return parseInt val
|
||||
|
||||
$(this).find('.sparkline').sparkline vals, width: '5em'
|
||||
|
||||
vals = $('table.list.dates tfoot th.quantity').map ->
|
||||
return parseInt $(this).html().replace(' ', '')
|
||||
|
||||
$('tfoot .sparkline').sparkline vals,
|
||||
type: 'bar'
|
||||
height: '3em'
|
||||
barWidth: '100%'
|
||||
barColor: '#9CC5EE'
|
@ -22,6 +22,9 @@ p.full_address
|
||||
span:last-child:after
|
||||
content: ''
|
||||
|
||||
.calendar-header, .month
|
||||
text-transform: capitalize
|
||||
|
||||
body.events.index table
|
||||
width: 90%
|
||||
max-width: 100%
|
||||
|
@ -1,5 +1,8 @@
|
||||
@import compass
|
||||
|
||||
.quantity
|
||||
text-align: right
|
||||
|
||||
table
|
||||
margin: 1em auto
|
||||
border-spacing: 2px
|
||||
@ -16,8 +19,6 @@ table
|
||||
font-size: larger
|
||||
td
|
||||
padding: 0.2em
|
||||
&.quantity
|
||||
text-align: right
|
||||
|
||||
dl
|
||||
margin: 1em auto
|
||||
@ -32,7 +33,6 @@ dl
|
||||
padding: 0.2em 1em
|
||||
text-align: left
|
||||
&.quantity
|
||||
text-align: right
|
||||
padding-right: 16em
|
||||
h3
|
||||
display: inline
|
||||
|
@ -33,3 +33,6 @@
|
||||
|
||||
body.stats h3
|
||||
text-align: center
|
||||
|
||||
.sparkline
|
||||
padding: 0
|
||||
|
@ -6,6 +6,12 @@ class RegionsController < InheritedResources::Base
|
||||
@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)')
|
||||
|
@ -9,7 +9,39 @@
|
||||
%dt=t '.allModeration'
|
||||
%dd.quantity= number_with_delimiter Event.unscoped.where(moderated: 0).count()
|
||||
|
||||
%h3=t '.regional'
|
||||
%h3
|
||||
%em.fa.fa-calendar
|
||||
=t '.dates'
|
||||
|
||||
%table.list.dates
|
||||
%thead
|
||||
%tr
|
||||
%th/
|
||||
- @year_events.each do |year|
|
||||
%th= year[0]
|
||||
%tbody
|
||||
- (1..12).each do |m|
|
||||
%tr
|
||||
%td.month= I18n.t('date.month_names')[m]
|
||||
- @year_events.each do |year|
|
||||
%td.quantity
|
||||
- line = @month_events.find { |line| line[0][0] == year[0] && line[0][1] == m }
|
||||
= number_with_delimiter line[1] if line
|
||||
%td.sparkline/
|
||||
|
||||
%tfoot
|
||||
%tr
|
||||
%th=t '.total'
|
||||
- @year_events.each do |year|
|
||||
%th.quantity= number_with_delimiter year[1]
|
||||
|
||||
%tr
|
||||
%th/
|
||||
%td.sparkline(colspan="#{@year_events.size}")/
|
||||
|
||||
%h3
|
||||
%em.fa.fa-shield
|
||||
=t '.regional'
|
||||
|
||||
%dl
|
||||
- @region_events.each do |region|
|
||||
@ -25,13 +57,6 @@
|
||||
%dt.item= city[0]
|
||||
%dd.quantity= number_with_delimiter city[1]
|
||||
|
||||
%h3=t '.dates'
|
||||
|
||||
%dl
|
||||
- @month_events.each do |month|
|
||||
%dt.item= l(Date.new(month[0][0].to_i, month[0][1].to_i), format: :month).capitalize
|
||||
%dd.quantity= number_with_delimiter month[1]
|
||||
|
||||
%h3=t '.web'
|
||||
|
||||
:markdown
|
||||
|
@ -1,8 +1,12 @@
|
||||
development:
|
||||
development_old:
|
||||
adapter: sqlite3
|
||||
pool: 5
|
||||
timeout: 5000
|
||||
database: db/development.sqlite3
|
||||
development:
|
||||
adapter: mysql2
|
||||
database: adl_fr
|
||||
username: manu
|
||||
|
||||
# Warning: The database defined as "test" will be erased and
|
||||
# re-generated from your development database when you run "rake".
|
||||
|
@ -134,11 +134,12 @@ it more readable or agreable.
|
||||
title: Statistics
|
||||
all: Validated events
|
||||
allModeration: Events waiting for validation
|
||||
dates: Per date
|
||||
regional: Per region
|
||||
city: Per city
|
||||
city_conditions: Only cities where more than 3 events have been organised
|
||||
are displayed.
|
||||
dates: Per date
|
||||
total: Total
|
||||
web: Web statistics
|
||||
webalizer: Statistics generated by Webalizer [are
|
||||
available](http://agendadulibre.org/stats/). They are protected by
|
||||
|
@ -132,11 +132,12 @@ fr:
|
||||
title: Statistiques
|
||||
all: Événements validés
|
||||
allModeration: Événements en cours de modération
|
||||
dates: Par date
|
||||
regional: Par région
|
||||
city: Par ville
|
||||
city_conditions: Seules les villes où plus de trois événements ont été
|
||||
organisés sont mentionnées.
|
||||
dates: Par date
|
||||
total: Total
|
||||
web: Statistiques Web
|
||||
webalizer: Des statistiques Web générées par Webalizer [sont
|
||||
disponibles](http://agendadulibre.org/stats/). Elles sont protégées par
|
||||
|
Loading…
Reference in New Issue
Block a user