Created
August 6, 2009 00:54
-
-
Save bernsno/163069 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
positions = Position.all(:conditions => ["name in (?)", ["wr","rb","te"]]) | |
players = Player.all(:conditions => ["position_id in (?)", positions.map(&:id)]) | |
rec_td_stat_name = StatName.find_by_title("Reception Touchdowns") | |
rush_td_stat_name = StatName.find_by_title("Rush Touchdowns") | |
rrtd_stat_name = StatName.find_by_title("Rushing and Receiving Touchdowns") | |
players.each do |player| | |
seasons = player.career_seasons | |
seasons.each do |season| | |
stats = [] | |
[rec_td_stat_name, rush_td_stat_name].each do |stat_name| | |
stats << player.career_stats.find_by_season_id_and_stat_name_id(season.id, stat_name).value | |
end | |
rrtds = player.career_stats.find_by_season_id_and_stat_name_id(season.id, rrtd_stat_name) | |
rrts.update_attribute :value, stats.sum | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment