Menu

Top Performers

six21
2004-11-02
2013-04-16
  • six21

    six21 - 2004-11-02

    To Lomn, Schwie

    I was just wondering if there were any plans to expand functionality (aka add new features).
    One feature that I would like to see and the team owners in my league have expressed the interest in seeing something along the lines of the top perfomers of the week.  Lets say top 10 performers according to points.  This info is there, I just cant figure out how the code goes since I'm a complete idiot when it comes to programming.

    Is this a possibiliy in the future?

    Thanks for all your hard work on this, my league has gone smoothly for a solid month now (minus the time I forgot to run my process rosters script!)

     
    • Stephen Rochelle

      Some sort of by-the-stats ranking is certainly something I'd like to see as well.  At this point, it's a question of being efficient enough to rate including -- my first attempt caused page creation times to skyrocket.  I've added a third dev who's much more comfortable with SQL than I am to see if he can help make the necessary overhead something we can live with.

      I had been thinking more along the lines of sorting the free agents listing, but I don't see any reason your suggestion would be any different from a programming standpoint, and it would be interesting to see.

       
    • Bill Rawlinson

      Bill Rawlinson - 2004-12-15

      I don't know if this will help or not but here - I made a mod to the function: getPlayers() in the file: offl_league.php

      To be honest, I can't figure out why the function hits the database so many times.  No matter what combination of parameters are passed in why cant the results be built in just one query call?  Im not super familiar with the constraints of mySQL but I figure it must support Outer Joins if there is a fear that an id in one table doesn't exist in another?  My experience is with Oracle and MS SQL so forgive me for not knowing why this function is designed this way.

      ==========getPlayers()============

           * Looks up players cross-referenced with various criteria.
           *
           * This function combines the functionality of lots of old (and mostly redundant) functions.  New parameters are a bit
           * heavy but I think the overall streamlined code is worthwhile.
           * Replaced:
           * <ul><li>getAllActivePlayers</li><li>getAllActiveFreeAgentPlayers</li><li>getAllPlayers</li><li>getAllPlayersByPosition</li></ul>
           *
           * @param integer $roster Optional: Default 0 returns all players.  1 returns only players on rosters.  2 returns only players not on rosters (players on waivers and free agents).  Combine with $waiver_status to get only free agents.
           * @param integer $waiver_status Optional: Default 0 returns all players.  1 returns only players on waivers.  2 returns only players not on waivers (free agents and players on rosters).  Combine with $roster to get only free agents.
           * @param integer $position_id Optional: Default 0 returns all players.  Otherwise returns only players with given {@link $_position_id}.
           * @param boolean $inactive Optional: Default FALSE returns only active players.  If TRUE, returns all inactive (as well as active) players.
           * @param string $orderby Optiona: Default 'lname, fname' returns ordered by lastname, firstname.  Also, auto apppends lname, fname as secondary sort columns
           * @return array Returns an array of {@link OFFL_Player} objects

           */
          function getPlayers($roster=0, $waiver_status=0, $position_id=0, $inactive=FALSE, $orderby='lname, fname')
          {
              $player_id_array = array();
              $retArr = array();
              $sql = "SELECT player_id FROM players";
              if ($position_id > 0)
              {
                  $sql .= " WHERE position_id=" . $position_id;
                  if (!$inactive)
                  {    $sql .= " AND active=1";    }
              }
              elseif (!$inactive)
              {    $sql .= " WHERE active=1";    }
              $result = mysql_query($sql,$this->_conn) or die (mysql_error() . ": $sql");

              for ($i = 0; $i < mysql_num_rows($result); $i++)
              {
                  $player_id_array[] = mysql_result($result, $i, "player_id");
              }
              mysql_free_result($result);

              switch ($roster)
              {
                  case 1:
                      $players_on_rosters = array();
                      $this->SQLQuery("SELECT player_id FROM `rosterplayers` WHERE league_id=" . $this->_league_id);
                      $num_players = $this->SQLNumRows();
                      for ($i = 0; $i < $num_players; $i++)
                      {    $players_on_rosters[] = $this->SQLResult($i, "player_id");    }
                     
      //                $teams = $this->getAllFFLTeams();
      //                $players_on_rosters = array();
      //                foreach ($teams as $team)
      //                {    $players_on_rosters = array_merge($players_on_rosters, $team->getRosterIDs(TRUE));    }

                      $player_id_array = array_intersect($player_id_array, $players_on_rosters);
                      unset ($players_on_rosters);

                      break;
                  case 2:
                      $players_on_rosters = array();
                      $this->SQLQuery("SELECT player_id FROM `rosterplayers` WHERE league_id=" . $this->_league_id);
                      $num_players = $this->SQLNumRows();
                      for ($i = 0; $i < $num_players; $i++)
                      {    $players_on_rosters[] = $this->SQLResult($i, "player_id");    }

      //                $teams = $this->getAllFFLTeams();
      //                $players_on_rosters = array();
      //                foreach ($teams as $team)
      //                {    $players_on_rosters = array_merge($players_on_rosters, $team->getRosterIDs(TRUE));    }

                      $player_id_array = array_diff($player_id_array, $players_on_rosters);
                      unset ($players_on_rosters);

                      break;
              }
              switch ($waiver_status)
              {
                  case 1:
                      $ws = new OFFL_WaiverPlayer();
                      $waiver_player_ids = array();
                      $waiver_players = $ws->getAllWaiverPlayers($this->_league_id);
                      foreach ($waiver_players as $wplayer)
                      {    $waiver_player_ids[] = $wplayer->getPlayerID();    }
                      unset ($waiver_players);

                      $player_id_array = array_intersect($player_id_array, $waiver_player_ids);
                      unset ($waiver_player_ids);

                      break;
                  case 2:
                      $ws = new OFFL_WaiverPlayer();
                      $waiver_player_ids = array();
                      $waiver_players = $ws->getAllWaiverPlayers($this->_league_id);
                      foreach ($waiver_players as $wplayer)
                      {    $waiver_player_ids[] = $wplayer->getPlayerID();    }
                      unset ($waiver_players);

                      $player_id_array = array_diff($player_id_array, $waiver_player_ids);
                      unset ($waiver_player_ids);

                      break;
              }

              $sql =
                  " SELECT ply.*, pos.*, tms.* FROM `players` ply, `positions` pos, `nflteams` tms" .
                  " WHERE ply.position_id=pos.position_id" .
                  " AND    ply.nflteam_id = tms.nflteam_id";

              if ($position_id > 0)
              {
                  $sql .= " AND ply.position_id=" . $position_id;
                  if (!$inactive)
                  {    $sql .= " AND active=1";    }
              }
              elseif (!$inactive)
              {    $sql .= " AND active=1";    }
              $sql .= "  ORDER BY " . $orderby;
              $result = mysql_query($sql,$this->_conn) or die (mysql_error() . ": $sql");
              while ($row = mysql_fetch_assoc($result))
              {
                  if( in_array($row["player_id"], $player_id_array) )
                  {
                      $player = new OFFL_Player();
                      $player->populateBySQLRow($row, $this->_league_id);
                      $retArr[] = $player;
                  }
              }

      //        foreach ($player_id_array as $player_id)
      //        {    $retArr[] = new OFFL_Player($player_id, $this->_league_id);    }

              return $retArr;
          }

      ==========END getPlayers()============

      Then I updated the file players.php from lines 75 - 133:

      adding:
                  if(empty($_REQUEST["orderby"])){
                      $_REQUEST["orderby"] = 'lname, fname';
                  } else {
                      $_REQUEST["orderby"] .= ', lname, fname';
                  }

      and then modifying the call to getPlayers to be:
                  $players = $myleague->getPlayers($_REQUEST["fa"], $waivers, $_REQUEST["position_id"],FALSE,$_REQUEST["orderby"]);

      and finally modifying the HTML table headers to be:

                          <th style="text-align:left; vertical-align:middle;"><a href="players.php">Name</a></th>
                          <th style="text-align:left; vertical-align:middle;"><a href="players.php?orderby=position_abbv">Position</a></th>
                          <th style="text-align:left; vertical-align:middle;"><a href="players.php?orderby=nflteam_abbv">NFL Team</a></th>

      I'd be happy to email this all to someone if it is necessary.

      Oh, I almost forgot. In the file teams.php on line 319 there is a very minor bug on a new install: the line has html commenting to block it out but it still raises a php error (probably due to the null return value)..

      <!--    <input type="hidden" name="fflteam_id" value="<?php /* echo $thisTeam->getFFLTeamID() */ ?>">    -->

      i added the php comment delmiters around the call to getFFLTeamID and that allowed me to create teams.

      Finally, the same error is generated on the page:
      standings.php?view=breakdown

      the error message is:
      Fatal error: Call to a member function getFFLTeamID() on a non-object in c:\Inetpub\wwwroot\offl\standings.php on line 348

      however, the error isn't so fatal that this page aborts like the teams page did.  unfortunately line 348 of the standings.php file isn't commented out html so I didn't make any effort to fix this yet (as it isn't really critical).

      If you want - email me at bill[[[AT]]]doxie[[[DOT]]]org and I will submit these as distinct issues and communicate with you on how best to submit fixes/enhancments as I come across them.

      thanks.
      Bill Rawlinson

       

Log in to post a comment.

MongoDB Logo MongoDB