X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=www%2Findex.pl;h=6f77c3323de3117a4bdae5d32a0c8ff734472029;hb=da3fa6c4de949158716dd130551cf6494f3766da;hp=a6b8cf043fdb92fb6cb945c627f9d7179875d814;hpb=69ada6cdd711047aca553a5242f8b878041737e9;p=foosball diff --git a/www/index.pl b/www/index.pl index a6b8cf0..6f77c33 100755 --- a/www/index.pl +++ b/www/index.pl @@ -62,9 +62,49 @@ while (my $ref = $q->fetchrow_hashref) { # Last games my @last_games = (); -$q = $dbh->prepare('select * from ( select to_char(gametime, \'IYYY-MM-DD HH24:MI\') as gametime,\'Double\' as type,team1_username1 || \' / \' || team1_username2 as username1, team2_username1 || \' / \' || team2_username2 as username2,score1,score2 from double_results union all select to_char(gametime, \'IYYY-MM-DD HH24:MI\') as gametime,\'Single\' as type,username1,username2,score1,score2 from single_results ) t1 order by gametime desc limit 10'); +$q = $dbh->prepare(' +select * from ( + select + to_char(gametime, \'IYYY-MM-DD HH24:MI\') as gametime, + \'Double\' as type, + team1_username1 || \' / \' || team1_username2 as username1, + team2_username1 || \' / \' || team2_username2 as username2, + score1, + score2, + ra1.rating_diff as diff1, + ra2.rating_diff as diff2 + from + double_results re + join double_rating ra1 + on re.gametime=ra1.ratetime + and re.team1_username1=ra1.username + join double_rating ra2 + on re.gametime=ra2.ratetime + and re.team2_username1=ra2.username + union all + select + to_char(gametime, \'IYYY-MM-DD HH24:MI\') as gametime, + \'Single\' as type, + username1, + username2, + score1, + score2, + ra1.rating_diff as diff1, + ra2.rating_diff as diff2 + from + single_results re + join single_rating ra1 + on re.gametime=ra1.ratetime + and re.username1=ra1.username + join single_rating ra2 + on re.gametime=ra2.ratetime + and re.username2=ra2.username +) t1 +order by gametime desc limit 10'); $q->execute(); while (my $ref = $q->fetchrow_hashref) { + $ref->{'diff1'} = sprintf "%+d", int($ref->{'diff1'} + 0.5); + $ref->{'diff2'} = sprintf "%+d", int($ref->{'diff2'} + 0.5); push @last_games, $ref; }