From 896e49b7266ea5abc350b16ccd01a02603e87adf Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 14 Feb 2005 15:43:33 +0000 Subject: [PATCH 01/16] Add buttons for setting paid/not paid (not validating, no backend). --- html/templates/registration.tmpl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/html/templates/registration.tmpl b/html/templates/registration.tmpl index 33b4162..bd0b4b5 100644 --- a/html/templates/registration.tmpl +++ b/html/templates/registration.tmpl @@ -45,6 +45,16 @@ [% ELSE %] ikke betalt [% END %] +
+ +[% IF r.paid %] + + +[% ELSE %] + + +[% END %] +
[% END %] -- 2.39.2 From ff31b7a6ebcff9cd50ca03706536ae8024fdd4e2 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 14 Feb 2005 15:49:59 +0000 Subject: [PATCH 02/16] Fix some validation errors, more remain. 15:15-16:45 --- html/templates/registration.tmpl | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/html/templates/registration.tmpl b/html/templates/registration.tmpl index bd0b4b5..44d7ab7 100644 --- a/html/templates/registration.tmpl +++ b/html/templates/registration.tmpl @@ -3,7 +3,6 @@
- @@ -26,6 +25,7 @@ @@ -36,27 +36,29 @@

PÃ¥meldte

-
    +
Spiller
+
[% FOR r = registered %] -
  • - [% r.nick %] - +
  • + [% IF r.paid %] - betalt + [% ELSE %] - ikke betalt + [% END %] - - + + [% END %] - +
    [% r.nick %]betaltikke betalt + + [% IF r.paid %] - - + + [% ELSE %] - - + + [% END %] - - + +
    -- 2.39.2 From 4af8a5f91e1da7ae80a4c86f853c052c01db297f Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 14 Feb 2005 18:12:58 +0000 Subject: [PATCH 03/16] Registration stuff now validates. --- html/ccbs.css | 3 +++ html/templates/registration.tmpl | 12 +++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/html/ccbs.css b/html/ccbs.css index 64f57aa..30d2365 100644 --- a/html/ccbs.css +++ b/html/ccbs.css @@ -76,6 +76,9 @@ a:visited { .notpaid { color: red; } +p.button { + margin: 0; +} /* IE sucks! */ tr.own td, tr.own th { border-top: 2px solid red; border-bottom: 2px solid red; } diff --git a/html/templates/registration.tmpl b/html/templates/registration.tmpl index 44d7ab7..cc41a21 100644 --- a/html/templates/registration.tmpl +++ b/html/templates/registration.tmpl @@ -47,14 +47,16 @@ [% END %]
    - +

    + [% IF r.paid %] - - + + [% ELSE %] - - + + [% END %] +

    -- 2.39.2 From 581c820151f988c2470c03d56dbca071432180ca Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 14 Feb 2005 18:16:42 +0000 Subject: [PATCH 04/16] Added backend for setting paid/not paid. --- html/do-set-paid.pl | 19 +++++++++++++++++++ html/templates/registration.tmpl | 1 + 2 files changed, 20 insertions(+) create mode 100755 html/do-set-paid.pl diff --git a/html/do-set-paid.pl b/html/do-set-paid.pl new file mode 100755 index 0000000..7ac795d --- /dev/null +++ b/html/do-set-paid.pl @@ -0,0 +1,19 @@ +#! /usr/bin/perl + +use ccbs; +use strict; +use warnings; + +my $dbh = ccbs::db_connect(); +my $cgi = new CGI; + +my $tournament = $cgi->param('tournament'); +my $player = $cgi->param('player'); +my $paid = $cgi->param('paid'); + +$dbh->do('UPDATE tournamentparticipation SET paid=? WHERE tournament=? AND player=?', + undef, $paid, $tournament, $player); + +ccbs::print_see_other('registration.pl?id=' . $tournament); + +$dbh->disconnect; diff --git a/html/templates/registration.tmpl b/html/templates/registration.tmpl index cc41a21..539ccb6 100644 --- a/html/templates/registration.tmpl +++ b/html/templates/registration.tmpl @@ -48,6 +48,7 @@

    + [% IF r.paid %] -- 2.39.2 From 566480373f7e1f45b748c7a0f34dcfed5c318730 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 14 Feb 2005 18:22:30 +0000 Subject: [PATCH 05/16] Add an option for un-registering people. --- html/do-unregister.pl | 18 ++++++++++++++++++ html/templates/registration.tmpl | 9 +++++++++ 2 files changed, 27 insertions(+) create mode 100755 html/do-unregister.pl diff --git a/html/do-unregister.pl b/html/do-unregister.pl new file mode 100755 index 0000000..3751e30 --- /dev/null +++ b/html/do-unregister.pl @@ -0,0 +1,18 @@ +#! /usr/bin/perl + +use ccbs; +use strict; +use warnings; + +my $dbh = ccbs::db_connect(); +my $cgi = new CGI; + +my $tournament = $cgi->param('tournament'); +my $player = $cgi->param('player'); + +$dbh->do('DELETE FROM tournamentparticipation WHERE tournament=? AND player=?', + undef, $tournament, $player); + +ccbs::print_see_other('registration.pl?id=' . $tournament); + +$dbh->disconnect; diff --git a/html/templates/registration.tmpl b/html/templates/registration.tmpl index 539ccb6..5a2239f 100644 --- a/html/templates/registration.tmpl +++ b/html/templates/registration.tmpl @@ -60,6 +60,15 @@

    + +
    +

    + + + +

    +
    + [% END %] -- 2.39.2 From 4b89e2730042ff56c716e46f87cdb8355f678d4d Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 14 Feb 2005 18:28:18 +0000 Subject: [PATCH 06/16] Added a link to "start tournament" in the tournament listing. --- html/templates/tournaments.tmpl | 1 + 1 file changed, 1 insertion(+) diff --git a/html/templates/tournaments.tmpl b/html/templates/tournaments.tmpl index eafa0e1..d21b379 100644 --- a/html/templates/tournaments.tmpl +++ b/html/templates/tournaments.tmpl @@ -17,6 +17,7 @@
  • [% t.tournamentname %] (registrering) + (begynn)
  • [% END %] -- 2.39.2 From 678e01bda4535cbf53ce4dbcd53f8b887c32be75 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 14 Feb 2005 18:44:40 +0000 Subject: [PATCH 07/16] Added a function for starting a tournament (no backend yet). --- html/start-tournament.pl | 21 +++++++++++++++++++++ html/templates/start-tournament.tmpl | 25 +++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100755 html/start-tournament.pl create mode 100644 html/templates/start-tournament.tmpl diff --git a/html/start-tournament.pl b/html/start-tournament.pl new file mode 100755 index 0000000..e6386f1 --- /dev/null +++ b/html/start-tournament.pl @@ -0,0 +1,21 @@ +#! /usr/bin/perl + +use ccbs; +use strict; +use warnings; + +my $cgi = new CGI; +my $id = $cgi->param('id'); + +my $dbh = ccbs::db_connect(); + +my $tournament = $dbh->selectrow_hashref('SELECT * FROM tournaments NATURAL JOIN seasons NATURAL JOIN countries NATURAL JOIN machines NATURAL JOIN scoringsystems WHERE tournament=?', undef, $id); +my $ref = $dbh->selectrow_hashref('SELECT count(*) AS num_registered FROM tournamentparticipation WHERE tournament=?', undef, $id); +my $num_registered = $ref->{'num_registered'}; + +ccbs::print_header(); +ccbs::process_template('start-tournament.tmpl', $tournament->{'tournamentname'}, { + tournament => $tournament, + num_registered => $num_registered +}); +$dbh->disconnect; diff --git a/html/templates/start-tournament.tmpl b/html/templates/start-tournament.tmpl new file mode 100644 index 0000000..d8769f3 --- /dev/null +++ b/html/templates/start-tournament.tmpl @@ -0,0 +1,25 @@ +[%# vim:set filetype=html: %] +
    +

    Det er for øyeblikket [% num_registered %] spillere registrert. + Du burde ikke starte en turnering før registreringen er stengt -- gå til + registreringen + om du ønsker å registrere flere før du starter turneringen.

    + +

    ADVARSEL: Om du bruker denne funksjonen underveis i en + turnering, vil alle data gå tapt! Denne funksjonen skal brukes én og bare én + gang i løpet av en turnering.

    + +
    + + + + + + + + +
    Antall grupper
    + +
    +
    +
    -- 2.39.2 From 6e5d70892c667ade86cc03a73339efe6f8c724b1 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 14 Feb 2005 18:55:29 +0000 Subject: [PATCH 08/16] Reverted separate start forms -- we'll generalize it instead. --- html/templates/start-tournament.tmpl | 25 ------------------------- html/templates/tournaments.tmpl | 1 - 2 files changed, 26 deletions(-) delete mode 100644 html/templates/start-tournament.tmpl diff --git a/html/templates/start-tournament.tmpl b/html/templates/start-tournament.tmpl deleted file mode 100644 index d8769f3..0000000 --- a/html/templates/start-tournament.tmpl +++ /dev/null @@ -1,25 +0,0 @@ -[%# vim:set filetype=html: %] -
    -

    Det er for øyeblikket [% num_registered %] spillere registrert. - Du burde ikke starte en turnering før registreringen er stengt -- gå til - registreringen - om du ønsker å registrere flere før du starter turneringen.

    - -

    ADVARSEL: Om du bruker denne funksjonen underveis i en - turnering, vil alle data gå tapt! Denne funksjonen skal brukes én og bare én - gang i løpet av en turnering.

    - -
    - - - - - - - - -
    Antall grupper
    - -
    -
    -
    diff --git a/html/templates/tournaments.tmpl b/html/templates/tournaments.tmpl index d21b379..eafa0e1 100644 --- a/html/templates/tournaments.tmpl +++ b/html/templates/tournaments.tmpl @@ -17,7 +17,6 @@
  • [% t.tournamentname %] (registrering) - (begynn)
  • [% END %] -- 2.39.2 From 22b4ad6760e9b0a21f799fa27af0c1be0d12c029 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 14 Feb 2005 19:10:27 +0000 Subject: [PATCH 09/16] Misc. changes -- some formatting and add a preliminary "start new round" form. --- html/show-tournament.pl | 5 ++- html/templates/show-tournament.tmpl | 63 +++++++++++++++++++++++------ 2 files changed, 54 insertions(+), 14 deletions(-) diff --git a/html/show-tournament.pl b/html/show-tournament.pl index b204270..87df626 100755 --- a/html/show-tournament.pl +++ b/html/show-tournament.pl @@ -61,10 +61,13 @@ for my $score (@$scores) { $pl->[$#$pl]->{'total'} += $score->{'score'}; } +my $num_rounds = scalar @rounds; + ccbs::print_header(); ccbs::process_template('show-tournament.tmpl', $tournament->{'tournamentname'}, { tournament => $tournament, rankings => $rankings, - rounds => \@rounds + rounds => \@rounds, + num_rounds => $num_rounds }); $dbh->disconnect; diff --git a/html/templates/show-tournament.tmpl b/html/templates/show-tournament.tmpl index 733b1cf..fac6ed0 100644 --- a/html/templates/show-tournament.tmpl +++ b/html/templates/show-tournament.tmpl @@ -1,30 +1,66 @@ [%# vim:set filetype=html: %]

    Generelle fakta

    -
      -
    • Sesong: [% tournament.seasonname %]
    • -
    • Land: [% tournament.countryname %]
    • -
    • Sted: [% tournament.location %]
    • -
    • Dato: [% tournament.date %]
    • -
    • Maskin: [% tournament.machinename %]
    • -
    • Scoresystem: [% tournament.scoringsystemname %]
    • -
    +
    +
      +
    • Sesong: [% tournament.seasonname %]
    • +
    • Land: [% tournament.countryname %]
    • +
    • Sted: [% tournament.location %]
    • +
    • Dato: [% tournament.date %]
    • +
    • Maskin: [% tournament.machinename %]
    • +
    • Scoresystem: [% tournament.scoringsystemname %]
    • +
    +
    + +

    Start ny runde

    + +
    +

    For øyeblikket har det vært avholdt [% num_rounds %] runder, + hvilket vil si at du kan begynne runde [% num_rounds + 1 %] + om du skulle ønske det. Vær oppmerksom på at du ikke kan begynne en ny runde + før den forrige er gjort helt ferdig.

    + +

    Det er [% num_qualified %] mennesker som vil gå videre til + neste runde, og disse vil bli spredd jevnt utover så mange grupper som du velger.

    + +
    + + + + + + + + + + +
    Antall grupper +
    Antall som går videre fra hver gruppe +
    + +
    +
    +

    Rankingliste

    -
      +
      +
        [% FOR r = rankings %] [% IF r.points == -1 %] -
      • [% r.ranking %]. plass: [% r.nick %]
      • +
      • [% r.ranking %]. plass: [% r.nick %]
      • [% ELSE %] -
      • [% r.ranking %]. plass: [% r.nick %], med [% r.points %] poeng.
      • +
      • [% r.ranking %]. plass: [% r.nick %], med [% r.points %] poeng.
      • [% END %] [% END %] -
      +
    + [% FOR r = rounds %]

    Runde [% r.round %]

    +
    + [% FOR p = r.parallels %] @@ -59,5 +95,6 @@ [% END %]
    [% END %] - + +
    [% END %] -- 2.39.2 From c73f95e10416d77bea35c2e409f3d6cd4b81143a Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 14 Feb 2005 19:15:37 +0000 Subject: [PATCH 10/16] Added a "number of people qualifying for each round" attribute to the SQL schema. --- sql/ccbs.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/ccbs.sql b/sql/ccbs.sql index c248214..c13c666 100644 --- a/sql/ccbs.sql +++ b/sql/ccbs.sql @@ -92,6 +92,7 @@ CREATE TABLE rounds ( round INTEGER NOT NULL, randomsongs INTEGER NOT NULL, chosensongs INTEGER NOT NULL, + numqualifying INTEGER, PRIMARY KEY (tournament, round) ); -- 2.39.2 From 54911b5a3fc854f29196895b5820ad6091001427 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 14 Feb 2005 19:32:16 +0000 Subject: [PATCH 11/16] Hide rankinglist if there is none. Count the number of qualified for next round. --- html/show-tournament.pl | 16 +++++++++++++++- html/templates/show-tournament.tmpl | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/html/show-tournament.pl b/html/show-tournament.pl index 87df626..57bd379 100755 --- a/html/show-tournament.pl +++ b/html/show-tournament.pl @@ -62,12 +62,26 @@ for my $score (@$scores) { } my $num_rounds = scalar @rounds; +my $num_rankings = scalar @$rankings; + +# If there have been no rounds, check out the number of participants; if not, check the +# number of qualified from the last round +my $num_qualified; +if ($num_rounds == 0) { + my $ref = $dbh->selectrow_hashref('SELECT COUNT(*) AS num_participants FROM tournamentparticipation WHERE tournament=?', undef, $id); + $num_qualified = $ref->{'num_participants'}; +} else { + my $ref = $dbh->selectrow_hashref('SELECT numqualifying FROM roundparticipation WHERE tournament=? AND round=?', undef, $id, $num_rounds); + $num_qualified = $ref->{'numqualifying'}; +} ccbs::print_header(); ccbs::process_template('show-tournament.tmpl', $tournament->{'tournamentname'}, { tournament => $tournament, rankings => $rankings, + num_rankings => $num_rankings, rounds => \@rounds, - num_rounds => $num_rounds + num_rounds => $num_rounds, + num_qualified => $num_qualified }); $dbh->disconnect; diff --git a/html/templates/show-tournament.tmpl b/html/templates/show-tournament.tmpl index fac6ed0..ad3a8e9 100644 --- a/html/templates/show-tournament.tmpl +++ b/html/templates/show-tournament.tmpl @@ -42,6 +42,7 @@ +[% IF num_rankings > 0 %]

    Rankingliste

    @@ -55,6 +56,7 @@ [% END %]
    +[% END %] [% FOR r = rounds %]

    Runde [% r.round %]

    -- 2.39.2 From f441216a623854ca492d416d0ebe825ae07ab40d Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 14 Feb 2005 19:44:08 +0000 Subject: [PATCH 12/16] Added preliminary backend for creating rounds and groups. --- html/do-start-round.pl | 27 +++++++++++++++++++++++++++ html/templates/show-tournament.tmpl | 10 ++++++++++ 2 files changed, 37 insertions(+) create mode 100755 html/do-start-round.pl diff --git a/html/do-start-round.pl b/html/do-start-round.pl new file mode 100755 index 0000000..5cd6779 --- /dev/null +++ b/html/do-start-round.pl @@ -0,0 +1,27 @@ +#! /usr/bin/perl + +use ccbs; +use strict; +use warnings; + +my $dbh = ccbs::db_connect(); +my $cgi = new CGI; + +my $tournament = $cgi->param('tournament'); +my $round = $cgi->param('round'); +my $num_random = $cgi->param('numrandom'); +my $num_chosen = $cgi->param('numchosen'); +my $num_groups = $cgi->param('numgroups'); +my $num_qual = $cgi->param('numqual'); + +$dbh->do('INSERT INTO rounds (tournament, round, randomsongs, chosensongs, numqualifying) VALUES (?, ?, ?, ?, ?)', + undef, $tournament, $round, $num_random, $num_chosen, $num_qual); + +for my $i (1..$num_groups) { + $dbh->do('INSERT INTO groups (tournament, round, parallel) VALUES (?, ?, ?)', + undef, $tournament, $round, $i); +} + +ccbs::print_see_other('show-tournamelt.pl?id=' . $tournament); + +$dbh->disconnect; diff --git a/html/templates/show-tournament.tmpl b/html/templates/show-tournament.tmpl index ad3a8e9..1ae4de1 100644 --- a/html/templates/show-tournament.tmpl +++ b/html/templates/show-tournament.tmpl @@ -33,8 +33,18 @@ Antall som går videre fra hver gruppe + + Antall tilfeldige sanger + + + + Antall selvvalgte sanger + + + + -- 2.39.2 From 182d123acc98ab1fd5139be06e671d46952abbf5 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 14 Feb 2005 20:25:35 +0000 Subject: [PATCH 13/16] Add people into groups. --- html/do-start-round.pl | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/html/do-start-round.pl b/html/do-start-round.pl index 5cd6779..2e503bb 100755 --- a/html/do-start-round.pl +++ b/html/do-start-round.pl @@ -14,6 +14,8 @@ my $num_chosen = $cgi->param('numchosen'); my $num_groups = $cgi->param('numgroups'); my $num_qual = $cgi->param('numqual'); +$dbh->{AutoCommit} = 0; + $dbh->do('INSERT INTO rounds (tournament, round, randomsongs, chosensongs, numqualifying) VALUES (?, ?, ?, ?, ?)', undef, $tournament, $round, $num_random, $num_chosen, $num_qual); @@ -22,6 +24,41 @@ for my $i (1..$num_groups) { undef, $tournament, $round, $i); } -ccbs::print_see_other('show-tournamelt.pl?id=' . $tournament); +# Seed people into groups (quite preliminary for now) +my $people; +if ($round == 1) { + $people = ccbs::db_fetch_all($dbh, 'SELECT * FROM players WHERE player IN ( SELECT player FROM tournamentparticipation WHERE tournament=? ) ORDER BY lower(nick)', + $tournament); +} else { + die "Fix qualifying later"; +} + +# Zigzag people to get the most fair groups possible +my $group = 1; +my $direction = 1; +my $position = 1; +for my $p (@$people) { + $dbh->do('INSERT INTO roundparticipation (tournament, round, parallel, player, position) VALUES (?, ?, ?, ?, ?)', undef, + $tournament, $round, $group, $p->{'player'}, $position); + + if ($group + $direction < 1 || $group + $direction > $num_groups) { + $direction = -$direction; + $position++; + } else { + $group += $direction; + } +} + +# Pick random songs for the groups (FIXME: add state to the random generator later) +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'); + $dbh->do('INSERT INTO roundrandomsongs (tournament, round, parallel, song) VALUES (?,?,?,?)', + undef, $tournament, $round, $g, $ref->{'song'}); + } +} + +ccbs::print_see_other('show-tournament.pl?id=' . $tournament); +$dbh->commit; $dbh->disconnect; -- 2.39.2 From b1e862cf469e55d500895e0a6abda81bd94cba7c Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 14 Feb 2005 20:35:22 +0000 Subject: [PATCH 14/16] Do LEFT JOINs to get out info for unfinished groups. --- html/show-tournament.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html/show-tournament.pl b/html/show-tournament.pl index 57bd379..30c1e51 100755 --- a/html/show-tournament.pl +++ b/html/show-tournament.pl @@ -15,7 +15,7 @@ my $rankings = ccbs::db_fetch_all($dbh, 'SELECT ranking,nick,COALESCE(points,-1) # 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,position,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 roundparticipation NATURAL LEFT JOIN roundrandomsongs NATURAL LEFT JOIN scores NATURAL JOIN songs NATURAL JOIN players WHERE tournament=? ORDER BY round,parallel,position,songnumber', $id); my @rounds = (); @@ -71,7 +71,7 @@ if ($num_rounds == 0) { my $ref = $dbh->selectrow_hashref('SELECT COUNT(*) AS num_participants FROM tournamentparticipation WHERE tournament=?', undef, $id); $num_qualified = $ref->{'num_participants'}; } else { - my $ref = $dbh->selectrow_hashref('SELECT numqualifying FROM roundparticipation WHERE tournament=? AND round=?', undef, $id, $num_rounds); + my $ref = $dbh->selectrow_hashref('SELECT numqualifying FROM rounds WHERE tournament=? AND round=?', undef, $id, $num_rounds); $num_qualified = $ref->{'numqualifying'}; } -- 2.39.2 From f3e1d3c28ccb302af953bc27c303c5256cc4e60e Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 14 Feb 2005 20:38:03 +0000 Subject: [PATCH 15/16] Correct number of qualified people from round >= 1. --- html/show-tournament.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/show-tournament.pl b/html/show-tournament.pl index 30c1e51..55bd2b4 100755 --- a/html/show-tournament.pl +++ b/html/show-tournament.pl @@ -71,7 +71,7 @@ if ($num_rounds == 0) { my $ref = $dbh->selectrow_hashref('SELECT COUNT(*) AS num_participants FROM tournamentparticipation WHERE tournament=?', undef, $id); $num_qualified = $ref->{'num_participants'}; } else { - my $ref = $dbh->selectrow_hashref('SELECT numqualifying FROM rounds WHERE tournament=? AND round=?', undef, $id, $num_rounds); + my $ref = $dbh->selectrow_hashref('SELECT SUM(numqualifying) AS numqualifying FROM rounds NATURAL JOIN groups WHERE tournament=? AND round=?', undef, $id, $num_rounds); $num_qualified = $ref->{'numqualifying'}; } -- 2.39.2