]> git.sesse.net Git - wloh/commitdiff
Add division view.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 18 Mar 2012 15:36:52 +0000 (16:36 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 18 Mar 2012 15:36:52 +0000 (16:36 +0100)
www/rating.pl

index 2727534c949e6c03cf14ac205ce142a72505f6d3..f6aa8e17a7af8ebb5ced200cd772c59e5b86489f 100755 (executable)
@@ -72,6 +72,35 @@ printf <<"EOF", $params{-3}, $match_stddev;
         150-0, 0-150 eller 150-150 ignoreres.</li>
     </ul>
 
+    <h2>Divisjonsoversikt</h2>
+
+    <table>
+      <tr>
+        <th>Div.</th>
+        <th>Snitt</th>
+        <th>Std.avvik</th>
+      </tr>
+EOF
+
+$q = $dbh->prepare('SELECT divisjon,AVG(rating) AS avg_rating,STDDEV(rating) AS stddev_rating FROM ratings NATURAL JOIN siste_divisjon GROUP BY divisjon ORDER BY divisjon');
+$q->execute;
+
+my $i = 0;
+while (my $ref = $q->fetchrow_hashref) {
+       if (++$i % 2 == 0) {
+               print "      <tr class=\"odd\">\n";
+       } else {
+               print "      <tr class=\"even\">\n";
+       }
+       printf "        <th>%d.</th>\n", $ref->{'divisjon'};
+       printf "        <td class=\"num\">%.1f</td>\n", $ref->{'avg_rating'};
+       printf "        <td class=\"num\">%.1f</td>\n", $ref->{'stddev_rating'};
+       print "      </tr>\n";
+}
+
+print <<"EOF";
+    </table>
+
   <h2>Rankingliste</h2>
 
   <table>
@@ -91,7 +120,7 @@ FROM ratings
 ORDER BY rating DESC');
 $q->execute;
 
-my $i = 0;
+$i = 0;
 while (my $ref = $q->fetchrow_hashref) {
        if (++$i % 2 == 0) {
                print "    <tr class=\"odd\">\n";