]> git.sesse.net Git - wloh/blobdiff - www/rating.pl
Add division view.
[wloh] / www / rating.pl
index d4a6f904253fbf6250ea6203af5ea40667cc07f7..f6aa8e17a7af8ebb5ced200cd772c59e5b86489f 100755 (executable)
@@ -35,32 +35,15 @@ printf <<"EOF", $params{-3}, $match_stddev;
 <html>
   <head>
     <title>WLoH-rating</title>
-    <style type="text/css">
-body {
-       color: black;
-       background: white;
-       font-family: sans-serif;
-}
-table {
-       border-collapse: collapse;
-       border: 1px solid black;
-}
-td, th {
-       border: 1px solid black;
-       padding: 5px;
-}
-td.num {
-       text-align: right;
-}
-.even {
-       background-color: #ddd;
-}
-    </style>
+    <link rel="stylesheet" href="/style" type="text/css" />
   </head>
   <body>
     <h1>WLoH-rating</h1>
 
-    <p>Ratingen er basert på spilledata fra WLoH (takk til Lobotommy
+    <p><em>Dette er et hobbyprosjekt fra tredjepart, og ikke en offisiell del av
+      <a href="http://wordfeud.aasmul.net/">Wordfeud Leage of Honour</a>.</em></p>
+
+    <p>Ratingen er dog basert på spilledata fra WLoH (takk til Lobotommy
       for tilgang!), og oppdateres
       hver hele time. Den er fullstendig uoffisiell, og har ingen innflytelse
       på WLoH, men brukes for å estimere vinnersannsynligheter i
@@ -89,6 +72,35 @@ td.num {
         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>
@@ -108,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";