Skip to content

Commit

Permalink
NflPlayers loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
tpadjen committed Aug 27, 2015
1 parent c9834dc commit d15b5cb
Show file tree
Hide file tree
Showing 17 changed files with 376 additions and 3 deletions.
24 changes: 24 additions & 0 deletions app/assets/stylesheets/home.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
// Place all the styles related to the home controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

li.qb {
background-color: blue;
}

li.rb {
background-color: red;
}

li.wr {
background-color: green;
}

li.te {
background-color: yellow;
}

li.def {
background-color: white;
}

li.k {
background-color: pink;
}
5 changes: 5 additions & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
class HomeController < ApplicationController

def index
@players = NflPlayer.all.order(projected_points: :desc)
end

end
10 changes: 10 additions & 0 deletions app/models/nfl_player.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class NflPlayer < ActiveRecord::Base
belongs_to :nfl_team

validates :position, inclusion: {in: ['QB', 'WR', 'RB', 'TE', 'DEF', 'K']}

def name
"#{first_name} #{last_name}".strip
end

end
2 changes: 2 additions & 0 deletions app/models/nfl_team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ class NflTeam < ActiveRecord::Base

validates :shortname, uniqueness: true

has_many :nfl_players

end
8 changes: 6 additions & 2 deletions app/views/home/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
<h2>Hello world</h2>
<p>The time is now <%= Time.now %></p>
<h1>All Players</h1>
<ul>
<% @players.each do |player| %>
<li class="<%= player.position.downcase %>"><%= player.name %> - <%= player.projected_points %></li>
<% end %>
</ul>
14 changes: 14 additions & 0 deletions db/migrate/20150827165014_create_nfl_players.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class CreateNflPlayers < ActiveRecord::Migration
def change
create_table :nfl_players do |t|
t.string :first_name
t.string :last_name
t.integer :rank
t.integer :position_rank
t.decimal :projected_points
t.references :nfl_team, index: true, foreign_key: true

t.timestamps null: false
end
end
end
5 changes: 5 additions & 0 deletions db/migrate/20150827171048_add_position_to_nfl_player.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddPositionToNflPlayer < ActiveRecord::Migration
def change
add_column :nfl_players, :position, :string
end
end
32 changes: 32 additions & 0 deletions db/players/def.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
1,11.1,Seahawks,,SEA
2,9.6,Dolphins,,MIA
3,9.4,Rams,,STL
4,9.1,Bills,,BUF
5,9.1,Eagles,,PHI
6,8.8,Colts,,IND
7,8.7,Patriots,,NE
8,8.7,Texans,,HOU
9,8.7,Browns,,CLE
10,8.6,Ravens,,BAL
11,8.5,Cardinals,,ARI
12,8.4,Jets,,NYJ
13,8.0,Packers,,GB
14,7.9,Broncos,,DEN
15,7.8,Vikings,,MIN
16,7.7,Bengals,,CIN
17,7.5,Titans,,TEN
18,7.4,Chargers,,SD
19,7.2,Panthers,,CAR
20,7.2,Chiefs,,KC
21,6.9,Saints,,NO
22,6.8,Lions,,DET
23,6.7,Buccaneers,,TB
24,6.6,Giants,,NYG
25,6.5,Steelers,,PIT
26,6.5,Falcons,,ATL
27,6.3,Cowboys,,DAL
28,5.8,Redskins,,WAS
29,5.5,Raiders,,OAK
30,5.3,Bears,,CHI
31,5.2,49ers,,SF
32,4.9,Jaguars,,JAC
12 changes: 12 additions & 0 deletions db/players/k.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
1,10.1,Tucker,Justin,BAL
2,9.3,Gostkowski,Stephen,NE
3,9.0,Zuerlein,Greg,STL
4,9.0,Vinatieri,Adam,IND
5,8.9,Bailey,Dan,DAL
6,8.8,Bryant,Matt,ATL
7,8.6,Crosby,Mason,GB
8,8.6,Parkey,Cody,PHI
9,8.6,Bullock,Randy,HOU
10,8.6,Hauschka,Steven,SEA
11,8.4,Carpenter,Dan,BUF
12,8.1,Brown,Josh,NYG
30 changes: 30 additions & 0 deletions db/players/qb.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
1,24.5,Luck,Andrew,IND
2,22.4,Rodgers,Aaron,GB
3,21.2,Wilson,Russel,SEA
4,19.3,Brees,Drew,NO
5,18.9,Ryan,Matt,ATL
6,18.5,Brady,Tom,NE
7,18.3,Manning,Peyton,DEN
8,18.2,Newton,Cam,CAR
9,17.7,Bridgewater,Teddy,MIN
10,17.2,Flacco,Joe,BAL
11,17.2,Foles,Nick,STL
12,17.2,Tannehill,Ryan,MIA
13,17.1,Romo,Tony,DAL
14,17.1,Roethlisberger,Ben,PIT
15,16.7,Bradford,Sam,PHI
16,16.7,Sanchez,Mark,PHI
17,16.7,Manning,Eli,NYG
18,16.6,Rivers,Philip,SD
19,16.5,Stafford,Matt,DET
20,16.2,Kaepernick,Colin,SF
21,16.0,Mariota,Marcus,TEN
22,15.4,Palmer,Carson,ARI
23,15.4,Glennon,Mike,TB
24,15.3,Griffen III,Robert,WAS
25,15.2,Cutler,Jay,CHI
26,15.1,Smith,Alex,KC
27,15.1,Taylor,Tyrod,BUF
28,15.0,Dalton,Andy,CIN
29,15.0,Nassib,Ryan,NYG
30,14.6,Carr,Derek,OAK
81 changes: 81 additions & 0 deletions db/players/rb.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
1,15.3,Bell,Le'veon,PIT
2,15.1,Peterson,Adrian,MIN
3,15.0,Lynch,Marshawn,SEA
4,13.8,Lacy,Eddie,GB
5,13.8,Charles,Jamaal,KC
6,13.6,Murray,DeMarco,PHI
7,13.4,McCoy,LeSean,BUF
8,13.0,Murray,Latavius,OAK
9,12.2,Forte,Matt,CHI
10,11.5,Gore,Frank,IND
11,11.4,Martin,Doug,TB
12,11.1,Hill,Jeremy,CIN
13,10.4,Morris,Alfred,WAS
14,10.4,Miller,Lamar,MIA
15,10.4,Randle,Joseph,DAL
16,10.0,Anderson,C.J.,DEN
17,10.0,Stewart,Jonathan,CAR
18,9.9,Ingram,Mark,NO
19,9.5,Forsett,Justin,BAL
20,9.3,Gurley,Todd,STL
21,9.3,Spiller,C.J.
22,9.2,Blount,LeGarrette,NE
23,8.9,Sankey,Bishop
24,8.8,Coleman,Tevin,STL
25,8.7,Ivory,Chris,NYJ
26,8.4,Johnson,David,ARI
27,8.4,Bell,Joique,DET
28,8.2,Vereen,Shane,NYG
29,8.2,Hyde,Carlos,SF
30,7.9,Bush,Reggie,SF
31,7.5,Crowell,Isiah,CLE
32,7.5,Blue,Alfred,HOU
33,7.3,Gordon,Melvin,SD
34,7.2,Taliaferro,Lorenzo,BAL
35,7.1,Williams,Andre,NYG
36,7.1,West,Terrance,CLE
37,7.0,Abdullah,Ameer,DET
38,6.9,Mathews,Ryan,PHI
39,6.8,Hillman,Ronnie,DEN
40,6.8,Yeldon,T.J.,JAC
41,6.6,Helu,Roy,OAK
42,6.5,Polk,Chris,HOU
43,6.4,Foster,Arian,HOU
44,6.4,Ellington,Andre,ARI
45,6.3,Tolbert,Mike,CAR
46,6.1,Woodhead,Danny,SD
47,6.1,Bernard,Gio,CIN
48,6.1,Jennings,Rashad,NYG
49,5.8,Thomas,Pierre,FA
50,5.8,McFadden,Darren,DAL
51,5.8,Robinson,Khiry,NO
52,5.6,Robinson,Denard,JAC
53,5.6,Mason,Tre,STL
54,5.6,Tipton,Zurlon,IND
55,5.5,Jackson,Fred,BUF
56,5.4,Smith,Antone,ATL
57,5.3,Cunningham,Benny,STL
58,5.3,Sproles,Darren,PHI
59,5.3,Gray,Jonas,NE
60,5.2,Freeman,Devonta,ATL
61,5.2,Davis,Knile,KC
62,5.1,Jones,Matt,WAS
63,4.8,Williams,Damien,MIA
64,4.8,Archer,Dri,PIT
65,4.8,Michael,Christine,SEA
66,4.6,Starks,James,GB
67,4.6,Asiata,Matt,MIN
68,4.5,Stacy,Zac,NYJ
69,4.5,Johnson,Duke,CLE
70,4.4,Cobb,David,TEN
71,4.4,Ball,Montee,DEN
72,4.4,Zenner,Zach,DET
73,4.4,Brown,Bryce,BUF
74,4.3,Williams,DeAngelo,PIT
75,4.2,Sims,Charles,TB
76,4.2,Jackson,Steven,FA
77,4.1,Moreno,Knowshon,MIA
78,4.1,Bradshaw,Ahmad,FA
79,4.1,Gerhart,Toby,JAC
80,4.1,Rice,Ray,BAL
81,4.0,Burkhead,Rex,CIN
30 changes: 30 additions & 0 deletions db/players/te.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
1,12.0,Gronkowski,Rob,NE
2,11.2,Graham,Jimmy,SEA
3,9.2,Kelce,Travis,KC
4,8.9,Olsen,Greg,CAR
5,8.2,Thomas,Julius,JAC
6,7.2,Cameron,Jordan,MIA
7,7.1,Allen,Dwayne,IND
8,7.1,Bennett,Martellus,CHI
9,6.9,Rudolph,Kyle,MIN
10,6.7,Fleener,Coby,IND
11,6.6,Eifert,Tyler,CIN
12,6.4,Cook,Jared,STL
13,6.3,Witten,Jason,DAL
14,6.3,Gates,Antonio,SD
15,6.1,Walker,Delanie,TEN
16,6.0,Donnell,Larry,NYG
17,5.8,Green,Virgil,DEN
18,5.5,Seferian-Jenkins,A,TB
19,5.4,Miller,Heath,PIT
20,4.9,Green,Ladarius,SD
21,4.9,Clay,Charles,BUF
22,4.8,Davis,Vernon,SF
23,4.7,Daniels,Owen,DEN
24,4.6,Reed,Jordan,WAS
25,4.3,Hill,Josh,NO
26,4.2,Celek,Brent,PHI
27,4.2,Amaro,Jace,NYJ
28,4.2,Barnidge,Gary,CLE
29,4.2,Ertz,Zach,PHI
30,3.9,Watson,Ben,NO
73 changes: 73 additions & 0 deletions db/players/wr.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
1,14.2,Jones,Julio,ATL
2,14.0,Beckham Jr., Odell,NYG
3,13.3,Brown,Antonio,PIT
4,13.1,Cooks,Brandin,NO
5,13.1,Bryant,Dez,DAL
6,12.9,Thomas,Demaryius,DEN
7,12.7,Johnson,Calvin,DET
8,12.7,Jeffrey,Alshon,CHI
9,12.5,Green,A.J.,CIN
10,12.0,Hilton,T.Y.,IND
11,11.4,Matthews,Jordan,PHI
12,10.9,Hopkins,DeAndre,HOU
13,10.7,Watkins,Sammy,BUF
14,10.5,Jackson,DeSean,WAS
15,10.5,Evans,Mike,TB
16,10.4,Cobb,Randall,GB
17,10.4,Maclin,Jeremy,KC
18,10.1,Wallace,Mike,MIN
19,9.8,Adams,Davante,GB
20,9.7,Smith,Torrey,SF
21,9.4,Sanders,Emmanuel,DEN
22,9.3,Brown,John,ARI
23,9.3,Johnson,Andre,IND
24,9.2,Edelman,Julian,NE
25,9.2,Garcon,Pierre,WAS
26,9.2,Johnson,Stevie,SD
27,9.0,Marshall,Brandon,NYJ
28,9.0,Tate,Golden,DET
29,8.9,Cooper,Amari,OAK
30,8.7,Allen,Keenan,SD
31,8.7,Jackson,Vincent,TB
32,8.6,Landry,Jarvis,MIA
33,8.5,Colston,Marques,NO
34,8.4,Wright,Kendall,TEN
35,8.3,Decker,Eric,NYJ
36,8.2,Fitzgerald,Larry,ARI
37,8.2,Boldin,Anquan,SF
38,8.0,Robinson,Allen,JAC
39,8.0,Britt,Kenny,STL
40,8.0,White,Roddy,ATL
41,7.6,Bryant,Martavis,PIT
42,7.3,Smith,Steve,BAL
43,7.2,Austin,Tavon,STL
44,7.1,Johnson,Charles,MIN
45,7.1,Agholor,Nelson,PHI
46,6.9,Quick,Brian,STL
47,6.9,Jones,Marvin,CIN
48,6.8,Cruz,Victor,NYG
49,6.7,Latimer,Cody,DEN
50,6.6,Funchess,Devin,CAR
51,6.6,LaFell,Brandon,NE
52,6.6,Shorts,Cecil,HOU
53,6.5,Perriman,Breshad,BAL
54,6.3,Hawkins,Andrew,CLE
55,6.2,Ellington,Bruce,SF
56,6.2,Williams,Terrance,DAL
57,6.2,Wheaton,Markus,PIT
58,6.1,Hurns,Allen,JAC
59,6.1,Bowe,Dwayne,CLE
60,6.1,Parker,Devante,MIA
61,6.1,Sanu,Mohamed,CIN
62,6.0,Floyd,Michael,ARI
63,5.9,Randle,Reuben,NYG
64,5.6,Cooper,Riley,PHI
65,5.6,Crabtree,Michael,OAK
66,5.6,Bailey,Stedman,STL
67,5.5,Royal,Eddie,CHI
68,5.4,Baldwin,Doug,SEA
69,5.4,Jennings,Greg,MIA
70,5.3,Stills,Kenny,MIA
71,5.3,Green-Beckham,Dorial,TEN
72,5.3,Wilson,Albert,KC
73,5.2,Patterson,Cordarrelle,MIN
17 changes: 16 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,25 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20150827163135) do
ActiveRecord::Schema.define(version: 20150827171048) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

create_table "nfl_players", force: :cascade do |t|
t.string "first_name"
t.string "last_name"
t.integer "rank"
t.integer "position_rank"
t.decimal "projected_points"
t.integer "nfl_team_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "position"
end

add_index "nfl_players", ["nfl_team_id"], name: "index_nfl_players_on_nfl_team_id", using: :btree

create_table "nfl_teams", force: :cascade do |t|
t.string "nickname"
t.string "city"
Expand All @@ -24,4 +38,5 @@
t.datetime "updated_at", null: false
end

add_foreign_key "nfl_players", "nfl_teams"
end
Loading

0 comments on commit d15b5cb

Please sign in to comment.