adarowski/Hall-of-Stats — pull request #1 by semanticart (2014-08-10 20:53:16+00:00)
Title: add concept of franchise durations for players

Getting this data into the views will require some work, so let's chat about that.

Also, those franchise pages are getting hefty and could use some performance love.

For now, though, this gets us the data. e.g.

```ruby
irb(main):005:0> player = Player.where(id: "baineha01").first
Player Load (0.3ms) SELECT "players".* FROM "players" WHERE "players"."id" = 'baineha01' LIMIT 1
=> #, war162_tot: #, wwar: #, hall_rating: #, position: "dh", hos: false, hof: false, eligibility: "eligible", peak_pct: 4.71, longevity_pct: 95.29, runs_bat: #, runs_br: #, runs_dp: #, runs_defense: #, runs_totalpos: #, pa: 11092, war_pos: #, war162_pos: #, waa_pos: #, ip_outs: nil, war_p: nil, war162_p: nil, waa_p: nil, war_tot: #, waa_tot: #, created_at: "2012-09-09 23:55:56", updated_at: "2014-03-04 02:47:06", photo_path: nil, bio: nil, first_year: 1980, last_year: 2001, runs_pitch: nil, img_url: nil, alt_hof: nil, cover_model: false, compatibility_id: "baineha01", ranking_overall: 737, ranking_position: 6, ranking_hof: nil, ranking_hos: nil, franchise_rankings: {"bal"=>{:hall_rating=>13.7751738611, :ranking=>134}, "chw"=>{:hall_rating=>36.5068029557, :ranking=>39}, "cle"=>{:hall_rating=>-0.2512845668, :ranking=>1362}, "oak"=>{:hall_rating=>5.2519291318, :ranking=>269}, "tex"=>{:hall_rating=>0.8283083868, :ranking=>353}}, personal_hof: false, hom: false, ross_hof: false, bryan_hof: false, consensus: 0, dan_hof: nil, dalton_hof: nil, nickname: nil, hof_year: nil, hof_via: nil>
irb(main):006:0> player.years_played_per_franchise
FranchisePlayerDuration Load (0.3ms) SELECT "franchise_player_durations".* FROM "franchise_player_durations" WHERE "franchise_player_durations"."player_id" = 'baineha01' ORDER BY start_year asc
=> {"chw"=>[[1980, 1989], [1996, 1997], [2000, 2001]], "tex"=>[[1989, 1990]], "oak"=>[[1990, 1992]], "bal"=>[[1993, 1995], [1997, 2000]], "cle"=>[[1999, 1999]]}
```