# 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'};
'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'};
'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;
<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>