X-Git-Url: https://git.sesse.net/?p=ccbs;a=blobdiff_plain;f=html%2Fshow-tournament.pl;h=c359511e54b6b332d76ef899b44f1072cff2e987;hp=999ea107bf0d017109e1ddcfc1f7b360342ea3cf;hb=f24e4feebe4555e63b5c5df1090f1982fed89f58;hpb=61fbc22bd19a5888abae2ff8b8bdf4b385e4d6ee diff --git a/html/show-tournament.pl b/html/show-tournament.pl index 999ea10..c359511 100755 --- a/html/show-tournament.pl +++ b/html/show-tournament.pl @@ -14,7 +14,7 @@ my $tournament = $dbh->selectrow_hashref('SELECT * FROM tournaments WHERE tourna # Swoop all the data in in a big join, then order it over to quasi-sane Perl objects. # (round -> parallel -> player -> songs -> title,chosen,score) my $scores = ccbs::db_fetch_all($dbh, - 'SELECT round,parallel,nick,title,chosen,score FROM scores NATURAL JOIN players NATURAL JOIN songs NATURAL JOIN roundparticipation WHERE tournament=? ORDER BY round,parallel,position,songnumber', + 'SELECT round,parallel,position,nick,title,chosen,score FROM scores NATURAL JOIN players NATURAL JOIN songs NATURAL JOIN roundparticipation WHERE tournament=? ORDER BY round,parallel,position,songnumber', $id); my @rounds = (); @@ -29,13 +29,26 @@ for my $score (@$scores) { my $p = $rounds[$#rounds]->{'parallels'}; if ($score->{'parallel'} != $parallel) { $parallel = $score->{'parallel'}; - push @$p, { parallel => $parallel, players => [] }; + push @$p, { parallel => $parallel, players => [], songs => [] }; $player = ''; + + # Information on songs is not selected from roundrandomsongs etc., + # but is filled in the first time the song is seen for this round + # (ie. below) + } + if ($score->{'position'} == 1) { + if ($score->{'chosen'}) { + push @{$p->[$#$p]->{'songs'}}, ''; + } else { + push @{$p->[$#$p]->{'songs'}}, $score->{'title'}; + } } + my $pl = $p->[$#$p]->{'players'}; if ($score->{'nick'} ne $player) { $player = $score->{'nick'}; push @$pl, { nick => $player, songs => [] }; + } push @{$pl->[$#$pl]->{'songs'}}, {