]> git.sesse.net Git - foosball/commitdiff
Show the number of games.
authorSteinar H. Gunderson <sesse@debian.org>
Sun, 21 Oct 2007 11:52:50 +0000 (13:52 +0200)
committerSteinar H. Gunderson <sesse@debian.org>
Sun, 21 Oct 2007 11:52:50 +0000 (13:52 +0200)
www/index.pl
www/index.xml

index c1ab7d17a2993e2dab12c7a66cfcb31556c88645..9d439751bde488156435cfd3f898a7a9c6b8878f 100755 (executable)
@@ -10,7 +10,7 @@ my $dbh = foosball::db_connect();
 
 # Single score board (whoa, inefficient)
 my @single_top = ();
-my $q = $dbh->prepare('select username from users');
+my $q = $dbh->prepare('select username,count(*) as num_games from single_rating group by username');
 $q->execute();
 while (my $ref = $q->fetchrow_hashref) {
        my $username = $ref->{'username'};
@@ -30,13 +30,14 @@ while (my $ref = $q->fetchrow_hashref) {
                'rd' => foosball::round($rd),
                'lowerbound' => foosball::round($rating - 3.0*$rd),
                'trend' => $trend,
+               'numgames' => $ref->{'num_games'},
        };
 }
 @single_top = sort { $b->{'lowerbound'} <=> $a->{'lowerbound'} } @single_top;
 
 # Double score board
 my @double_top = ();
-$q = $dbh->prepare('select username from users');
+$q = $dbh->prepare('select username,count(*) as num_games from double_rating group by username');
 $q->execute();
 while (my $ref = $q->fetchrow_hashref) {
        my $username = $ref->{'username'};
@@ -56,6 +57,7 @@ while (my $ref = $q->fetchrow_hashref) {
                'rd' => foosball::round($rd),
                'lowerbound' => foosball::round($rating - 3.0*$rd),
                'trend' => $trend,
+               'numgames' => $ref->{'num_games'},
        };
 }
 @double_top = sort { $b->{'lowerbound'} <=> $a->{'lowerbound'} } @double_top;
index a1b248801d018078b2a3781487ece48278778770..b7297cc720f124cd88300c706e1040322e2f67c0 100644 (file)
             <th class="rating">Rating</th>
             <th class="rd">RD</th>
             <th class="lowerbound">Bound</th>
+            <th class="numgames">Games</th>
             <th class="trend">Change</th>
           </tr>
         </thead>
             <td class="rating"><t:rating /></td>
             <td class="rd"><t:rd /></td>
             <td class="lowerbound"><t:lowerbound /></td>
+            <td class="numgames"><t:numgames /></td>
             <td class="trend"><t:trend /></td>
           </tr>
         </tbody>
             <th class="rating">Rating</th>
             <th class="rd">RD</th>
             <th class="lowerbound">Bound</th>
+            <th class="numgames">Games</th>
             <th class="trend">Change</th>
           </tr>
         </thead>
             <td class="rating"><t:rating /></td>
             <td class="rd"><t:rd /></td>
             <td class="lowerbound"><t:lowerbound /></td>
+            <td class="numgames"><t:numgames /></td>
             <td class="trend"><t:trend /></td>
           </tr>
         </tbody>