From: Steinar H. Gunderson Date: Sat, 17 Mar 2012 18:05:57 +0000 (+0100) Subject: Do not print relegation information for the lowest division. X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=9c7574772a1b1caec8427c8c8e5c50c9d2b4e125;p=wloh Do not print relegation information for the lowest division. --- diff --git a/www/index.pl b/www/index.pl index 3329935..ff0c7ce 100755 --- a/www/index.pl +++ b/www/index.pl @@ -39,7 +39,7 @@ sub color { } sub make_table { - my $used_ratings = shift; + my ($lowest_division, $used_ratings) = @_; print <<"EOF"; @@ -90,7 +90,7 @@ EOF for my $i (1..$num_games) { print " $i.\n"; } - print " NEDRYKK\n"; + print " NEDRYKK\n" unless ($lowest_division); print " \n"; for my $player (sort { $a cmp $b } keys %prob) { @@ -106,14 +106,14 @@ EOF if ($i == 1) { ($g, $b) = ($b, $g); - } elsif ($i >= $num_games - 1) { + } elsif ($i >= $num_games - 1 && !$lowest_division) { ($r, $b) = ($b, $r); } printf " %.1f%%\n", $pn * 100.0; } - { + unless ($lowest_division) { my $pn = ($prob{$player}->[$num_games - 1] + $prob{$player}->[$num_games - 2]) / $trials; my $r = color(1.0); @@ -141,6 +141,7 @@ $match_stddev = $parms{-2} * sqrt(2.0); my $season; my $division = $cgi->param('divisjon') // -1; my $subdivision = $cgi->param('avdeling') // -1; +my $last_division = 0; POSIX::setlocale(&POSIX::LC_ALL, 'nb_NO.UTF-8'); @@ -197,6 +198,7 @@ $q = $dbh->prepare('SELECT DISTINCT(divisjon) FROM fotballserier WHERE sesong=? $q->execute($season); my $found_division = 0; +my $max_division; while (my $ref = $q->fetchrow_hashref) { my $d = $ref->{'divisjon'}; @@ -206,6 +208,7 @@ while (my $ref = $q->fetchrow_hashref) { } else { print " \n"; } + $max_division = $d; } $division = 1 if (!$found_division); @@ -269,8 +272,8 @@ while (my $ref = $q->fetchrow_hashref) { } $q->finish; - -make_table({}); +my $lowest_division = ($division == $max_division); +make_table($lowest_division, {}); print <<"EOF";

Under er en variant som prøver å ta relativ spillestyrke med i betraktningen. @@ -278,7 +281,7 @@ print <<"EOF"; men modellen er foreløpig ikke fullstendig tunet.

EOF -make_table(\%ratings); +make_table($lowest_division, \%ratings); print << "EOF";