X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=www%2Findex.pl;h=c31200a59586c5260fbadb8533cebdca7b95af64;hb=ea27f7d09fc8c7e3b284e0e248c37a126583faf9;hp=6f77c3323de3117a4bdae5d32a0c8ff734472029;hpb=b31d5b814e17e45e04c6941b5ed698b85e8807af;p=foosball diff --git a/www/index.pl b/www/index.pl index 6f77c33..c31200a 100755 --- a/www/index.pl +++ b/www/index.pl @@ -72,7 +72,9 @@ select * from ( score1, score2, ra1.rating_diff as diff1, - ra2.rating_diff as diff2 + ra2.rating_diff as diff2, + ra3.rating_diff as diff3, + ra4.rating_diff as diff4 from double_results re join double_rating ra1 @@ -80,7 +82,13 @@ select * from ( and re.team1_username1=ra1.username join double_rating ra2 on re.gametime=ra2.ratetime - and re.team2_username1=ra2.username + and re.team1_username2=ra2.username + join double_rating ra3 + on re.gametime=ra3.ratetime + and re.team2_username1=ra3.username + join double_rating ra4 + on re.gametime=ra4.ratetime + and re.team2_username2=ra4.username union all select to_char(gametime, \'IYYY-MM-DD HH24:MI\') as gametime, @@ -90,7 +98,9 @@ select * from ( score1, score2, ra1.rating_diff as diff1, - ra2.rating_diff as diff2 + null as diff2, + ra2.rating_diff as diff3, + null as diff4 from single_results re join single_rating ra1 @@ -103,8 +113,17 @@ select * from ( 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); + if (defined($ref->{'diff2'})) { + $ref->{'diff1'} = sprintf "%+d / %+d", + int($ref->{'diff1'} + 0.5), + int($ref->{'diff2'} + 0.5); + $ref->{'diff2'} = sprintf "%+d / %+d", + int($ref->{'diff3'} + 0.5), + int($ref->{'diff4'} + 0.5); + } else { + $ref->{'diff1'} = sprintf "%+d", int($ref->{'diff1'} + 0.5); + $ref->{'diff2'} = sprintf "%+d", int($ref->{'diff3'} + 0.5); + } push @last_games, $ref; }