Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Updating/Scoring

Help
bigworm
2013-03-21
2014-03-20
  • bigworm
    bigworm
    2013-03-21

    When I udpate my master bracket I get an error about the tiebreaker, although the winning teams are saved.   No scoring update is done.

    When I click score all brackets I get "Duplicate entry 'main-1' for key 'PRIMARY'"

     
  • cnyballer
    cnyballer
    2013-03-21

    I forget when it was fixed but I remember I used to have this issue.  Had to enter a value in tiebreaker field when editing master bracket.

     
  • bigworm
    bigworm
    2013-03-21

    I remembered that as well and have been doing that..the weird thing is when the first game was over I edited the master bracket and everything was fine.

    The error happens after the master when it goes to score all.

     
  • bigworm
    bigworm
    2013-03-21

    Going in through mysql truncating table scores and best_scores and then clicking on score all allowed it to work…

    If I click on score all again it does not work…

    The score.php has the command to truncate these two tables in it…is it possible something has changed or it needs to be moved up?  I am running the latest official release with the handful of changes from trunk

     
  • cnyballer
    cnyballer
    2013-03-21

    If you want to compare, here's a copy of the score.php code I'm using ok..

    <?php

    include("database.php");
    include 'functions.php';
    validatecookie();

    function scoreBrackets( $db, $master_data, $loserMap, $roundMap, $seedMap, $scoringType)
    {

    $custompoints = getScoringArray($db, $scoringType);
    $query = "SELECT * FROM `brackets`";
    $result = mysql_query($query,$db);

    while ($user_bracket = mysql_fetch_array($result, MYSQL_ASSOC))
    {
    $score = 0;
    $bestScore = 0;

    for($j=1;$j<64;++$j)
    {
    // calculate actual score
    if($user_bracket == $master_data && $user_bracket != "" )
    {
    $seedvalue = $seedMap[ $master_data ];
    $score += $custompoints[ $roundMap ];
    }

    // calcualte best score
    if( ( $user_bracket == $master_data || $loserMap[ $user_bracket ] == false )
    && $user_bracket != ""  )
    {
    $seedvalue = $seedMap[ $user_bracket ];
    $bestScore += $custompoints[ $roundMap ];
    }

    }

    if ($user_bracket > 0)
    {
    $score_query = "INSERT INTO `scores` () VALUES ('$user_bracket','$user_bracket','$score','$scoringType')";

    mysql_query($score_query,$db) or die(mysql_error());

    $score_query = "INSERT INTO `best_scores` () VALUES ('$user_bracket','$user_bracket','$bestScore','$scoringType')";
    mysql_query($score_query,$db) or die(mysql_error());
    }
    }

    }

    //completely clear all scoreboards to be repopulated
    $clear_query= "TRUNCATE TABLE `scores";
    mysql_query($clear_query,$db);
    $clear_query= "TRUNCATE TABLE `best_scores";
    mysql_query($clear_query,$db);

    $master_query = "SELECT * FROM `master` WHERE `id`=2"; //winners
    $master_data = mysql_query($master_query,$db);
    $master_data = mysql_fetch_array($master_data);

    $seedMap = getSeedMap($db);
    $roundMap = getRoundMap();
    $loserMap = getLoserMap($db);

    scoreBrackets( $db, $master_data, $loserMap, $roundMap, $seedMap, 'main');
    scoreBrackets( $db, $master_data, $loserMap, $roundMap, $seedMap, 'geometric');
    scoreBrackets( $db, $master_data, $loserMap, $roundMap, $seedMap, 'espn');
    scoreBrackets( $db, $master_data, $loserMap, $roundMap, $seedMap, 'fibonacci');
    scoreBrackets( $db, $master_data, $loserMap, $roundMap, $seedMap, 'odds');
    scoreBrackets( $db, $master_data, $loserMap, $roundMap, $seedMap, 'constant');

    $gamesLeft = 0;

    // only 63 games in yourney
    for( $i=1; $i<64; $i++ )
    {
    if( $master_data == "" )
    {
    $gamesLeft++;
    }
    }

    // 11 may be able to execute before timing out
    if( $gamesLeft >= 11 )
    {
    header( 'Location: index.php' );
    }
    else
    {
    header( 'Location: calculate_paths_to_victory.php' );
    }
    ?>

     
  • bigworm
    bigworm
    2013-03-22

    I reverted from trunk to the latest official release and still have this problem…have to truncate those two tables manually for scoring to update.

     
  • Rob J
    Rob J
    2013-03-22

    FYI I have never encountered this problem. Do you have the latest table definition? Maybe one of the constraints on the master table is weird

     
  • bigworm
    bigworm
    2013-03-22

    Here is my master table info

    CREATE TABLE `master` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `1` varchar(32) NOT NULL DEFAULT '',
      `2` varchar(32) NOT NULL DEFAULT '',
      `3` varchar(32) NOT NULL DEFAULT '',
      `4` varchar(32) NOT NULL DEFAULT '',
      `5` varchar(32) NOT NULL DEFAULT '',
      `6` varchar(32) NOT NULL DEFAULT '',
      `7` varchar(32) NOT NULL DEFAULT '',
      `8` varchar(32) NOT NULL DEFAULT '',
      `9` varchar(32) NOT NULL DEFAULT '',
      `10` varchar(32) NOT NULL DEFAULT '',
      `11` varchar(32) NOT NULL DEFAULT '',
      `12` varchar(32) NOT NULL DEFAULT '',
      `13` varchar(32) NOT NULL DEFAULT '',
      `14` varchar(32) NOT NULL DEFAULT '',
      `15` varchar(32) NOT NULL DEFAULT '',
      `16` varchar(32) NOT NULL DEFAULT '',
      `17` varchar(32) NOT NULL DEFAULT '',
      `18` varchar(32) NOT NULL DEFAULT '',
      `19` varchar(32) NOT NULL DEFAULT '',
      `20` varchar(32) NOT NULL DEFAULT '',
      `21` varchar(32) NOT NULL DEFAULT '',
      `22` varchar(32) NOT NULL DEFAULT '',
      `23` varchar(32) NOT NULL DEFAULT '',
      `24` varchar(32) NOT NULL DEFAULT '',
      `25` varchar(32) NOT NULL DEFAULT '',
      `26` varchar(32) NOT NULL DEFAULT '',
      `27` varchar(32) NOT NULL DEFAULT '',
      `28` varchar(32) NOT NULL DEFAULT '',
      `29` varchar(32) NOT NULL DEFAULT '',
      `30` varchar(32) NOT NULL DEFAULT '',
      `31` varchar(32) NOT NULL DEFAULT '',
      `32` varchar(32) NOT NULL DEFAULT '',
      `33` varchar(32) NOT NULL DEFAULT '',
      `34` varchar(32) NOT NULL DEFAULT '',
      `35` varchar(32) NOT NULL DEFAULT '',
      `36` varchar(32) NOT NULL DEFAULT '',
      `37` varchar(32) NOT NULL DEFAULT '',
      `38` varchar(32) NOT NULL DEFAULT '',
      `39` varchar(32) NOT NULL DEFAULT '',
      `40` varchar(32) NOT NULL DEFAULT '',
      `41` varchar(32) NOT NULL DEFAULT '',
      `42` varchar(32) NOT NULL DEFAULT '',
      `43` varchar(32) NOT NULL DEFAULT '',
      `44` varchar(32) NOT NULL DEFAULT '',
      `45` varchar(32) NOT NULL DEFAULT '',
      `46` varchar(32) NOT NULL DEFAULT '',
      `47` varchar(32) NOT NULL DEFAULT '',
      `48` varchar(32) NOT NULL DEFAULT '',
      `49` varchar(32) NOT NULL DEFAULT '',
      `50` varchar(32) NOT NULL DEFAULT '',
      `51` varchar(32) NOT NULL DEFAULT '',
      `52` varchar(32) NOT NULL DEFAULT '',
      `53` varchar(32) NOT NULL DEFAULT '',
      `54` varchar(32) NOT NULL DEFAULT '',
      `55` varchar(32) NOT NULL DEFAULT '',
      `56` varchar(32) NOT NULL DEFAULT '',
      `57` varchar(32) NOT NULL DEFAULT '',
      `58` varchar(32) NOT NULL DEFAULT '',
      `59` varchar(32) NOT NULL DEFAULT '',
      `60` varchar(32) NOT NULL DEFAULT '',
      `61` varchar(32) NOT NULL DEFAULT '',
      `62` varchar(32) NOT NULL DEFAULT '',
      `63` varchar(32) NOT NULL DEFAULT '',
      `64` varchar(32) NOT NULL DEFAULT '',
      `type` varchar(32) DEFAULT NULL,
      PRIMARY KEY (`id`),
      UNIQUE KEY `type` (`type`)
    ) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=latin1$$
    
     
  • bigworm
    bigworm
    2013-03-22

    Here are the other two tables that I have to truncate to get the scoring to work..

    CREATE TABLE `scores` (
      `id` int(11) NOT NULL DEFAULT '0',
      `name` varchar(128) NOT NULL DEFAULT '',
      `score` double NOT NULL DEFAULT '0',
      `scoring_type` varchar(255) NOT NULL DEFAULT '',
      PRIMARY KEY (`scoring_type`,`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1$$
    CREATE TABLE `scoring` (
      `seed` int(11) NOT NULL DEFAULT '0',
      `1` double DEFAULT NULL,
      `2` double DEFAULT NULL,
      `3` double DEFAULT NULL,
      `4` double DEFAULT NULL,
      `5` double DEFAULT NULL,
      `6` double DEFAULT NULL,
      `type` char(255) DEFAULT NULL,
      KEY `system` (`type`,`seed`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1$$
    
     
  • bigworm
    bigworm
    2013-03-22

    My install was from latest trunk on 03-18

     
  • bigworm
    bigworm
    2013-03-22

    sorry, the two tables I have to truncate are scores and best_scores

    CREATE TABLE `best_scores` (
      `id` int(11) NOT NULL DEFAULT '0',
      `name` varchar(128) NOT NULL DEFAULT '',
      `score` double NOT NULL DEFAULT '0',
      `scoring_type` varchar(255) NOT NULL DEFAULT '',
      PRIMARY KEY (`scoring_type`,`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1$$
    
     
  • bigworm
    bigworm
    2013-03-22

    I just compared the structure.sql from my install to the 1.5.3.6 and they are identical.

     
  • bigworm
    bigworm
    2013-03-22

    Putting a little error catch in the score.php right after the truncate commands gives me this message for both tables

    Invalid query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`best_scores' at line 1 Whole query: TRUNCATE TABLE `best_scores
    

    I am running php 5.4 and mysql 5.6.10

     
  • bigworm
    bigworm
    2013-03-22

    Changing the query to the following seems to have fixed it…all the documentation I found indicates that php requires the ` after the table name.

    //completely clear all scoreboards to be repopulated
    $clear_query= "TRUNCATE TABLE `scores`";
    mysql_query($clear_query,$db);
    if ( !$clear_query ) print(mysql_error());
    $clear_query= "TRUNCATE TABLE `best_scores`";
    mysql_query($clear_query,$db);
    if ( !$clear_query ) print(mysql_error());
    
     
  • Rob J
    Rob J
    2013-03-23

    Thanks for figuring this out. I've updated this in the latest release.

     
  • cnyballer
    cnyballer
    2014-03-20

    I feel like I've run into this in the past but don't remember the solution or if there is 1. I have 25 paid brackets and 2 non-paid. I'd like the non-paid to show up in the standings . I marked them exempt even and they don't show in the standings. Is this possible? Also, is there a way to distinguish them from the paid brackets in the standings?