Kilg.us – Fantasy Stat Tracker …Tracker

A blog about the development of Kilg.us – The Fantasy Baseball Stat Tracker

Posts Tagged ‘Status’

Player Stat Gathering

Saturday, June 7th, 2008

Today I built-out the mechanism for gathering players’ stats. In the original model, every time anyone loaded a Team page in the Fantasy Stat Tracker, a request was made for each player for an XML file on mlb.com with that player’s stats. It worked, but it seemed like a little overkill. If multiple Users with the same player checked their pages, multiple requests would be made for that player’s stats. If a single User re-loaded their Team page, requests were made for every single player’s stats whether the stats had changed or not.

In the new model, the Fantasy Stat Tracker gathers a player’s stats and saves them to the database with a timestamp for when the stats XML file was last updated. For subsequent stat requests the application first checks if the player’s stats file has been updated on the remote server. If it hasn’t, it simply uses the existing stats in the database. If the stats file has been updated, it will be downloaded, saved to the database with a new timestamp, and the updated stats will be used.

Theoretically this should speed up the Fantasy Stat Tracker a bit. Downloading stats from a remote server takes longer than getting them from a local database. By removing most of the requests for remote stats files, the application should be able to render Team pages quicker.

In addition, by using local stats in most instances instead of downloading them, the Fantasy Stat Tracker should dramatically cut down its bandwidth usage. With the current number of Users and requests in the application, bandwidth isn’t really an issue yet. But if the Stat Tracker becomes more popular, hopefully it’s future-proofed a bit.

One complication with this new stat gathering method is that it is very difficult to test. I can’t fiddle with file dates on mlb.com so I can’t test how the new code will work as the day rolls over to tomorrow and new games begin. If you see any errors in the application, I’d appreciate if you could copy the text of the error message and shoot it to me in an email at fantasy.stat.tracker@gmail.com. Thanks for your help in making the Fantasy Stat Tracker better!

Email Address and Password Updates

Sunday, June 1st, 2008

The Fantasy Baseball Stat Tracker has some new user account management functionality. It is now possible to change your email address and password. Both options are available through the “Account Info” page in the top-right navigation.

Players Updated Again

Saturday, May 31st, 2008

I just ran the player-updater script again, so all the latest roster additions should now be in the system. New players include:

  • Jay Bruce
  • Andy Philips
  • Jeff Bailey
  • Grant Balfour
  • Scott Elarton
  • Mike Aviles
  • Jeff Larish
  • Joe Nelson
  • Russell Branyan
  • Clayton Kershaw
  • Terry Tiffee
  • Nick Evans
  • Brian Horwitz

Once I smarten-up, I’ll set that updater script to run nightly to make sure the player list is always up-to-date. Until then, I’ll just try to remember to run it manually. If you can’t find a player that you think should be listed, please let me know and I’ll try to get him pulled in.

Customize the Stats you Track

Monday, May 26th, 2008

Today saw the addition of functionality to allow users to define which stats will be displayed for each team. When viewing your team’s live stats, you can now click a “Select Stats” link in the Roster nav. This will take you to a simple page that lists all the stats available in the Fantasy Baseball Stat Tracker. If you have previously defined a selection of stats to track, those will be pre-checked for inclusion. You can check or uncheck stats to add or remove them from a team’s display.

Stats are handled on a team-by-team basis. So if you have multiple teams within the Stat Tracker, you can define a different set of statistics for each team.

If you have not defined which stats to display for a team, you will automatically be shown all available statistical categories. When you go to define the stats for your team, though, none of the checkboxes will be pre-checked. You’ll need to explicitly select each statistic you wish to track.

Updated Player List

Friday, May 23rd, 2008

I’ve re-written how the Fantasy Stat Tracker is gathering its player list. Previously it was pulling data that was created before the season started. This left the application without a few dozen players and some players with incorrect information (players on the wrong teams or with incorrect positions). The application is now capable of pulling player data from daily game stats. This means that I can run the process to grab player data and have it pull in everything updated to the current day. Rookies and other new players will be added, and positions will be updated if they change.

In most fantasy leagues, as players play a new position they ALSO become available at that position rather than replacing their old position with the new one. Because the Fantasy Stat Tracker isn’t as much about your roster and league rules as it is about the stats for the players, I don’t see the behavior of replacing positions as being too troublesome. When I run out of things to work on, though, I’ll look into listing players with all their applicable positions.

Search for Players

Friday, May 23rd, 2008

I found a little time to work on the Fantasy Stat Tracker this morning and put it to use adding functionality to search through players when adding a player to your team. Previously the Add Player function offered a laundry list of every player in the application. By using your browser’s built-in search function it wasn’t too difficult to find the player you were looking for–but it wasn’t ideal. You can now search by first and/or last name as well as filter results by position. By default, the Add Player page still provides the laundry list, should that be an effective mechanism for you.

Player searches are performed via a Post back to the Add Player page, meaning a round-trip to the server each time you search. Filtering by position, though, is handled on the fly. For some reason, the first time you filter by a position the application takes a few seconds before updating the list. After the first round, though, it happens almost instantaneously.

I also fixed a bug that was introduced last week when I added links to the player detail pages on MLB.com. I had originally built the display to pop-up a JavaScript alert when you requested to Remove a player from your team. That alert read the content of the table cell holding the player’s name. After adding in the link to the MLB.com page, this caused the alert to display a string of HTML/JavaScript instead of just the player’s name. I updated it to look within the anchor element for the player’s name so the alert pops-up with just the player’s name again.

Lack of Progress

Sunday, May 18th, 2008

For the second half of last week I was laid up with some kind of food poisoning or cold (yeah, so bad I couldn’t even lay around and code…). Now I’ve spent the weekend watching some real, live baseball and preparing for a camping trip. Next I’ll be heading out on said camping trip. So not much has changed on the Fantasy Stat Tracker recently and nothing will for the next few days. Hopefully later this week I’ll be able to get back to work. My apologies for the delays.

Lots of changes today

Wednesday, May 14th, 2008

There were a number of nice additions to the Fantasy Stat Tracker today. Among them:

  • Change team name – edit the name of a team you have created
  • Delete team – remove a team from your account
  • Linked player names – player names now link to the player’s MLB.com profile page
  • Google Analytics – added GA webstats to the site
  • View Team link – added a link to the “account nav” to link to your team’s stats page (or render a drop-down list if you have multiple teams)

I also moved the “home page” link from the footer up to the “blog nav”. So we now have links to the blog home page and the Fantasy Stat Tracker home page in the top left corner of the page. The addition of the “view team” link and the relocation of the home link already seem to make it a lot easier to navigate the tool. As I mentioned the other day, though, I’ll be continuing to look at the navigation architecture for the site.

Along with the additions mentioned above, I performed a number of minor code enhancements. I worked on better escaping of SQL strings to be sent to the DB and some advancements in auto-redirecting users about the site based on whether or not the user account has a team associated with it (or multiple teams). There is also a check in place now to prevent people from accessing teams’ stats for other peoples’ teams. Previously you could edit the Location bar to change the TeamID that was being passed and see other peoples’ teams. You wouldn’t have been able to make any changes, but you could view the team nonetheless. Now you can’t.

Most noticeably, I re-organized the home page and brought a log-on form directly onto the page. The Fantasy Stat Tracker home page content was re-written slightly to better explain the free nature of this project. Some advertising verbiage was also added to encourage people to sign-up for an account.

Mother’s Day Updates

Sunday, May 11th, 2008

Just a few minor tweaks today. I cleaned up the “create account” process a bit. It’s still not elegant, but it at least gives an error if you try to create an account using an existing Username or Email. I’ve also added a footer with a link to the homepage (not sure if that’s actually valuable or not…) and a link to email a Fantasy Stat Tracker account I set up with Google.

Now that the application is starting to get a few pieces of functionality, I’m noticing the need for a navigation structure. Currently the application has the following navigation:

  1. Blog nav—top-left: links to the blog
  2. Account nav—top-right: links to manage account-level things
  3. Team nav—below banner-right: links to manage on the team-level
  4. Footer nav—site-wide links

This seems like a pretty disparate navigation scheme. I’ll have to tighten it up and try to make an architecture of pages/functions in the application.

Sign Up Now!

Friday, May 9th, 2008

It is now possible to sign up for an account on the Fantasy Stat Tracker, build your team, and track your stats! I’ve finished the functionality just in the last few minutes, so there is A LOT of work yet to do–rough edges to smooth, data to validate, workflows to finesse. But…the basic functionality works! There is no warning if your email duplicates an existing one (it will fail silently and won’t create your account). It also isn’t checking whether user names exist already, so it’s possible to duplicate users. That means down the road I might flush the database to get rid of crap data. So, if you sign up now, I don’t promise I won’t erase your account as development continues. I’ll try not to, though.

I was able to create an account and build a 25-man roster in less than 5 minutes. Please, give it a shot, and let me know what you think. Please post comments on the Fantasy Stat Tracker back to this blog post.

Enjoy!