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