#! /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 $parallel = $cgi->param('parallel');

$dbh->{AutoCommit} = 0;

$dbh->do('DELETE FROM bigscreen.active_groups WHERE tournament=? AND round=? AND parallel=?', undef,
	$tournament, $round, $parallel);
if ($cgi->param('show') eq 'true') {
	$dbh->do('INSERT INTO bigscreen.active_groups (tournament, round, parallel) VALUES (?,?,?)',
		undef, $tournament, $round, $parallel);
}

$dbh->do('NOTIFY active_groups');

$dbh->commit;
$dbh->disconnect;

ccbs::print_see_other('show-tournament.pl?id=' . $tournament);

