]> git.sesse.net Git - wloh/commitdiff
Do not print relegation information for the lowest division.
authorSteinar H. Gunderson <Steinar H. Gunderson sesse@debian.org>
Sat, 17 Mar 2012 18:05:57 +0000 (19:05 +0100)
committerSteinar H. Gunderson <Steinar H. Gunderson sesse@debian.org>
Sat, 17 Mar 2012 18:05:57 +0000 (19:05 +0100)
www/index.pl

index 332993595a98937ec279dd7f6be5398ea9b7309f..ff0c7ce5a990c7d3ad47e7f75d82b99cfa7e1d5b 100755 (executable)
@@ -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 "        <th>$i.</th>\n";
        }
-       print "        <th>NEDRYKK</th>\n";
+       print "        <th>NEDRYKK</th>\n" unless ($lowest_division);
        print "      </tr>\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 "        <td style=\"background-color: rgb($r, $g, $b)\">%.1f%%</td>\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 "        <option value=\"$d\">$d</option>\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";
     <p>Under er en variant som pr&oslash;ver &aring; ta relativ spillestyrke med i betraktningen.
@@ -278,7 +281,7 @@ print <<"EOF";
       men modellen er forel&oslash;pig ikke fullstendig tunet.</p>
 EOF
 
-make_table(\%ratings);
+make_table($lowest_division, \%ratings);
 
 print << "EOF";
     </table>