diff options
Diffstat (limited to 'data/tpl/vnpage_stats')
-rw-r--r-- | data/tpl/vnpage_stats | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/data/tpl/vnpage_stats b/data/tpl/vnpage_stats index 7108486e..d5d002a7 100644 --- a/data/tpl/vnpage_stats +++ b/data/tpl/vnpage_stats @@ -1,13 +1,17 @@ <ul id="stats"> + [[ my $max = 1; my $total = 0; my $sum = 0; - for (0..$#{$d{votes}{graph}}) { - $total += $d{votes}{graph}[$_]; - $max = $d{votes}{graph}[$_] if $d{votes}{graph}[$_] > $max; - $sum += ($_+1) * $d{votes}{graph}[$_]; + + if($d{votes}{graph}) { + for (0..$#{$d{votes}{graph}}) { + $total += $d{votes}{graph}[$_]; + $max = $d{votes}{graph}[$_] if $d{votes}{graph}[$_] > $max; + $sum += ($_+1) * $d{votes}{graph}[$_]; + } } ]] -[[ if(!$d{user} || ($d{pv} && $d{user}{votes})) { ]]- +[[ if($d{votes}{graph} && $d{pv} && $d{user}{votes}) { ]]- <li><h3>Vote graph <p class="actions">[[= $total ]]- vote[[= $total==1?'':'s' ]]- total [[= $total ? sprintf(', average: %.1f.', $sum/$total) : '' ]]</p></h3> <table id="tvg"> |