Fantasy Golf Tracking with Node.js, MongoDB, AngularJS, and Bootstrap - Part 1 June 21, 2014
My family and a bunch of friends are in a fantasy golf league together. The rules are pretty straightforward, although probably not standard.
Rules:
1. Pay $50
2. 10 Tournaments that span the PGA Tour season.
3. Pick 6 golfers before the first tee times on Thursday typically.
4. 4 lowest scores are added and that's your score for each day.
5. If 3 of your players miss the cut, you are assigned the worst score at the end of round 3, pretty much destroying your chance to win.
6. Lowest score wins. $50 payoff for majors (Masters, US Open, British Open, PGA Championship), $25 for the other tournaments.
My brother Pat is the score keeper and chairman of the league. The data collection and reporting was pretty much done in Excel. This is a fine method for doing such things. The scores would be emailed out along with entertaining commentary.
But then it was my turn to do the data since Pat was going to Boston for the US Open weekend to visit some friends.
Excel was not a viable solution.
I happened to stumble on the PGA Tour Leaderboard website. I noticed that the data is loading in asynchronously, which could only mean AJAX. The question was, which format, and what data is available?
The answer was the start of this application. The data is JSON. And EVERYTHING is available. (I hope I don't get in too much trouble for grabbing it :). Well, everything I needed and some extra stuff.
The first step to building this app was to determine what the Information Architecture was going to look like. Here's what I came up with:
Teams: Name, Email address of a person in the league.
Tournaments: Tournament info include URL to the JSON file on pgatour.com, data like start / end date, is it in progress, is it finished.
Team Tournament: Each team's 6 initial golfers for each tournament, and total score recording.
Pulling in the tournament from the pgatour.com JSON file pulls in all of the information required for a tournament in my system, so all that is needed as input is the JSON file URL!
Next you assign teams. There can be 6 max.
Then scores are calculated.
And updated throughout the round, each day, for the whole tournament.
If a player doesn't have 4 players make the cut, they are given a substitute. The worst score from the 3rd round.
That is pretty much everything! Once again, working with AngularJS is a breeze.
Check out the site at fantasygolf.jasontconnell.com! There you can view the source to get an idea of how it was written. It was very simple that I don't even feel like I can post any difficult code that I wrote, but it's just that it's really cool. Our next tournament is the Congressional next week, I hope everyone in the league uses the site. I added GA tracking so I'll know for sure :)