Permalink
Browse files

Add more stats on moderation

  • Loading branch information...
1 parent e0f6239 commit 5dbd08420226b2d78611fc1033038f4606918b53 Benoît Sibaud committed with nono May 6, 2012
Showing with 27 additions and 10 deletions.
  1. +5 −0 app/models/statistics/moderation.rb
  2. +22 −10 app/views/statistics/moderation.html.haml
@@ -18,6 +18,7 @@ def average_time
SELECT YEAR(CONVERT_TZ(nodes.created_at,'+00:00','Europe/Paris')) AS year,
COUNT(*) AS cnt,
SUM(TIMESTAMPDIFF(SECOND,news.created_at,nodes.created_at)) AS duration,
+ STD(TIMESTAMPDIFF(SECOND,news.created_at,nodes.created_at)) AS std,
MIN(TIMESTAMPDIFF(SECOND,news.created_at,nodes.created_at)) AS min,
MAX(TIMESTAMPDIFF(SECOND,news.created_at,nodes.created_at)) AS max
FROM nodes, news
@@ -29,6 +30,10 @@ def average_time
EOS
end
+ def median_time(year, count, percentile)
+ count("SELECT TIMESTAMPDIFF(SECOND,news.created_at,nodes.created_at) AS duration FROM nodes, news WHERE nodes.content_id = news.id AND nodes.content_type='News' AND YEAR(CONVERT_TZ(nodes.created_at,'+00:00','Europe/Paris'))='#{year}' ORDER BY duration LIMIT #{(count*percentile).to_i},1;", "duration")
+ end
+
def top_amr(sql_criterion="")
select_all <<-EOS
SELECT login, moderator_id, COUNT(*) AS cnt
@@ -29,18 +29,30 @@
%td
.stat.misc(style="width: #{(width_stats * day["cnt"] / maxval).to_i}px;")= day["cnt"]
- %h2 Temps de modération
+ %h2 Temps d'édition et de modération
%p
- Temps moyen passé entre la création d'une dépêche (temps d'édition compris) et sa modération finale&nbsp;:
- %ul
+ Temps passé entre la création d'une dépêche (temps d'édition compris) et sa modération finale&nbsp;:
+ %table{'class'=>'sortable'}
+ %tr
+ %th Année
+ %th Médiane (h)
+ %th 95e percentile (h)
+ %th Moyenne (h)
+ %th Écart-type (h)
+ %th Minimum (min)
+ %th Maximum (h)
- @stats.average_time.each do |avg|
- %li
- - if avg["cnt"] > 0
- #{avg["year"]}&nbsp;: #{(avg["duration"]/(avg["cnt"]*3600)).to_i} heures (entre #{(avg["min"]/60).to_i}min et #{(avg["max"]/3600).to_i}h)
- - else
- aucune information disponible
-
- -# TODO Temps médian... un peu pénible à calculer...
+ - if avg["cnt"] > 0
+ %tr
+ %td{'class'=>'stat'}= avg["year"]
+ %td{'class'=>'stat'}= (@stats.median_time(avg["year"],avg["cnt"],0.50)/3600)
+ %td{'class'=>'stat'}= (@stats.median_time(avg["year"],avg["cnt"],0.95)/3600)
+ %td{'class'=>'stat'}= (avg["duration"]/(avg["cnt"]*3600)).to_i
+ %td{'class'=>'stat'}= (avg["std"]/3600).to_i
+ %td{'class'=>'stat'}= (avg["min"]/60).to_i
+ %td{'class'=>'stat'}= (avg["max"]/3600).to_i
+ - else
+ aucune information disponible
%h2 Équipe de modération
%ul

0 comments on commit 5dbd084

Please sign in to comment.