X-Git-Url: https://git.sesse.net/?p=ccbs;a=blobdiff_plain;f=html%2Fdo-start-round.pl;h=2637076503eddb76584864307c6f6555323f4a92;hp=ff0a4178068b46e1273794bb2d1d5981d9984e78;hb=9e9977d8d73f4f28e6f8f3d6d1a007a859bc3955;hpb=81edbdf60931cc5343964a86e95a43a4dfd6d103 diff --git a/html/do-start-round.pl b/html/do-start-round.pl index ff0a417..2637076 100755 --- a/html/do-start-round.pl +++ b/html/do-start-round.pl @@ -49,10 +49,16 @@ for my $p (@$people) { } } -# Pick random songs for the groups (FIXME: add state to the random generator later) +# Pick random songs for the groups for my $g (1..$num_groups) { for my $s (1..$num_random) { - my $ref = $dbh->selectrow_hashref('SELECT * FROM songs ORDER BY random() LIMIT 1'); + my $ref = $dbh->selectrow_hashref('SELECT * FROM machinesongs WHERE song NOT IN ( SELECT song FROM randomsongsused ) AND machine=( SELECT machine FROM tournaments WHERE tournament=? ) ORDER BY random() LIMIT 1', + undef, $tournament); + if (!defined($ref)) { + ccbs::user_error('Det er ikke flere sanger igjen i sangvelgeren!'); + } + $dbh->do('INSERT INTO randomsongsused (song) VALUES (?)', + undef, $ref->{'song'}); $dbh->do('INSERT INTO roundrandomsongs (tournament, round, parallel, song) VALUES (?,?,?,?)', undef, $tournament, $round, $g, $ref->{'song'});