stattleship-ruby 0.1.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.rubocop.yml +263 -0
- data/.ruby-version +1 -0
- data/.travis.yml +8 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +15 -0
- data/LICENSE +1 -0
- data/README.md +75 -0
- data/Rakefile +1 -0
- data/bin/console +7 -0
- data/bin/game_log_officials +32 -0
- data/bin/game_logs +69 -0
- data/bin/games +42 -0
- data/bin/in_progress +19 -0
- data/bin/injuries +18 -0
- data/bin/officials +42 -0
- data/bin/players +45 -0
- data/bin/scoreboard +43 -0
- data/bin/setup +7 -0
- data/bin/stat_leaders +25 -0
- data/bin/team_game_logs +35 -0
- data/bin/teams +29 -0
- data/bin/top_stats +25 -0
- data/bin/total_player_stat +33 -0
- data/bin/total_team_stat +22 -0
- data/examples/README.md +118 -0
- data/examples/baseball_feats.rb +35 -0
- data/examples/baseball_games.rb +32 -0
- data/examples/baseball_player_game_logs.rb +33 -0
- data/examples/baseball_stat_leaders.rb +30 -0
- data/examples/basketball_game_logs.rb +33 -0
- data/examples/basketball_injuries.rb +36 -0
- data/examples/basketball_season_player_performance_rankings.rb +31 -0
- data/examples/basketball_stat_leaders.rb +40 -0
- data/examples/basketball_team_game_logs.rb +38 -0
- data/examples/basketball_top_stats.rb +43 -0
- data/examples/basketball_winning_streaks.rb +27 -0
- data/examples/bears_team_game_logs.rb +46 -0
- data/examples/football_feats.rb +49 -0
- data/examples/football_game_logs.rb +40 -0
- data/examples/football_players.rb +43 -0
- data/examples/football_stats.rb +50 -0
- data/examples/football_total_player_stat.rb +32 -0
- data/examples/hockey_games.rb +56 -0
- data/examples/hockey_penalties.rb +47 -0
- data/examples/hockey_scoring_plays.rb +55 -0
- data/examples/hockey_team_ranked_streaks.rb +27 -0
- data/examples/hockey_teams.rb +54 -0
- data/examples/hockey_total_team_stat.rb +32 -0
- data/examples/sample.env +2 -0
- data/lib/stattleship.rb +117 -0
- data/lib/stattleship/baseball_feats.rb +15 -0
- data/lib/stattleship/baseball_game_logs.rb +159 -0
- data/lib/stattleship/baseball_games.rb +15 -0
- data/lib/stattleship/baseball_injuries.rb +15 -0
- data/lib/stattleship/baseball_penalties.rb +15 -0
- data/lib/stattleship/baseball_players.rb +15 -0
- data/lib/stattleship/baseball_scoring_plays.rb +15 -0
- data/lib/stattleship/baseball_stat_leaders.rb +15 -0
- data/lib/stattleship/baseball_stats.rb +15 -0
- data/lib/stattleship/baseball_team_game_logs.rb +142 -0
- data/lib/stattleship/baseball_team_outcome_streaks.rb +15 -0
- data/lib/stattleship/baseball_teams.rb +15 -0
- data/lib/stattleship/baseball_top_stats.rb +15 -0
- data/lib/stattleship/baseball_total_player_stat.rb +15 -0
- data/lib/stattleship/baseball_total_team_stat.rb +15 -0
- data/lib/stattleship/basketball_feats.rb +15 -0
- data/lib/stattleship/basketball_game_logs.rb +111 -0
- data/lib/stattleship/basketball_games.rb +15 -0
- data/lib/stattleship/basketball_injuries.rb +15 -0
- data/lib/stattleship/basketball_penalties.rb +15 -0
- data/lib/stattleship/basketball_players.rb +15 -0
- data/lib/stattleship/basketball_scoring_plays.rb +15 -0
- data/lib/stattleship/basketball_stat_leaders.rb +15 -0
- data/lib/stattleship/basketball_stats.rb +15 -0
- data/lib/stattleship/basketball_team_game_logs.rb +113 -0
- data/lib/stattleship/basketball_team_outcome_streaks.rb +15 -0
- data/lib/stattleship/basketball_teams.rb +15 -0
- data/lib/stattleship/basketball_top_stats.rb +15 -0
- data/lib/stattleship/basketball_total_player_stat.rb +15 -0
- data/lib/stattleship/basketball_total_team_stat.rb +15 -0
- data/lib/stattleship/client/client.rb +101 -0
- data/lib/stattleship/client/configuration.rb +42 -0
- data/lib/stattleship/endpoint.rb +208 -0
- data/lib/stattleship/feats.rb +150 -0
- data/lib/stattleship/football_feats.rb +15 -0
- data/lib/stattleship/football_game_logs.rb +255 -0
- data/lib/stattleship/football_games.rb +15 -0
- data/lib/stattleship/football_injuries.rb +15 -0
- data/lib/stattleship/football_penalties.rb +15 -0
- data/lib/stattleship/football_players.rb +15 -0
- data/lib/stattleship/football_scoring_plays.rb +15 -0
- data/lib/stattleship/football_stat_leaders.rb +15 -0
- data/lib/stattleship/football_stats.rb +15 -0
- data/lib/stattleship/football_team_game_logs.rb +176 -0
- data/lib/stattleship/football_team_outcome_streaks.rb +15 -0
- data/lib/stattleship/football_teams.rb +15 -0
- data/lib/stattleship/football_top_stats.rb +15 -0
- data/lib/stattleship/football_total_player_stat.rb +15 -0
- data/lib/stattleship/football_total_team_stat.rb +15 -0
- data/lib/stattleship/formatters/stat_formatter.rb +28 -0
- data/lib/stattleship/game_logs.rb +97 -0
- data/lib/stattleship/games.rb +38 -0
- data/lib/stattleship/hockey_feats.rb +15 -0
- data/lib/stattleship/hockey_game_logs.rb +107 -0
- data/lib/stattleship/hockey_games.rb +15 -0
- data/lib/stattleship/hockey_injuries.rb +15 -0
- data/lib/stattleship/hockey_penalties.rb +32 -0
- data/lib/stattleship/hockey_players.rb +15 -0
- data/lib/stattleship/hockey_scoring_plays.rb +15 -0
- data/lib/stattleship/hockey_stat_leaders.rb +15 -0
- data/lib/stattleship/hockey_stats.rb +15 -0
- data/lib/stattleship/hockey_team_game_logs.rb +128 -0
- data/lib/stattleship/hockey_team_outcome_streaks.rb +15 -0
- data/lib/stattleship/hockey_teams.rb +15 -0
- data/lib/stattleship/hockey_top_stats.rb +15 -0
- data/lib/stattleship/hockey_total_player_stat.rb +15 -0
- data/lib/stattleship/hockey_total_team_stat.rb +15 -0
- data/lib/stattleship/injuries.rb +32 -0
- data/lib/stattleship/models.rb +19 -0
- data/lib/stattleship/models/game.rb +360 -0
- data/lib/stattleship/models/injury.rb +22 -0
- data/lib/stattleship/models/league.rb +35 -0
- data/lib/stattleship/models/official.rb +20 -0
- data/lib/stattleship/models/penalty.rb +133 -0
- data/lib/stattleship/models/player.rb +124 -0
- data/lib/stattleship/models/playing_position.rb +17 -0
- data/lib/stattleship/models/ranking.rb +96 -0
- data/lib/stattleship/models/scoring_play.rb +201 -0
- data/lib/stattleship/models/scoring_player.rb +22 -0
- data/lib/stattleship/models/season.rb +18 -0
- data/lib/stattleship/models/team.rb +78 -0
- data/lib/stattleship/models/team_outcome_streak.rb +88 -0
- data/lib/stattleship/models/venue.rb +32 -0
- data/lib/stattleship/params.rb +102 -0
- data/lib/stattleship/params/baseball_feats_params.rb +6 -0
- data/lib/stattleship/params/baseball_game_logs_params.rb +6 -0
- data/lib/stattleship/params/baseball_games_params.rb +6 -0
- data/lib/stattleship/params/baseball_injuries_params.rb +6 -0
- data/lib/stattleship/params/baseball_penalties_params.rb +6 -0
- data/lib/stattleship/params/baseball_players_params.rb +6 -0
- data/lib/stattleship/params/baseball_scoring_plays_params.rb +6 -0
- data/lib/stattleship/params/baseball_stat_leaders_params.rb +6 -0
- data/lib/stattleship/params/baseball_stats_params.rb +6 -0
- data/lib/stattleship/params/baseball_team_game_logs_params.rb +6 -0
- data/lib/stattleship/params/baseball_team_outcome_streaks_params.rb +9 -0
- data/lib/stattleship/params/baseball_team_stats_params.rb +10 -0
- data/lib/stattleship/params/baseball_teams_params.rb +6 -0
- data/lib/stattleship/params/baseball_top_stats_params.rb +6 -0
- data/lib/stattleship/params/baseball_total_player_stat_params.rb +6 -0
- data/lib/stattleship/params/baseball_total_team_stat_params.rb +11 -0
- data/lib/stattleship/params/basketball_feats_params.rb +6 -0
- data/lib/stattleship/params/basketball_game_logs_params.rb +6 -0
- data/lib/stattleship/params/basketball_games_params.rb +6 -0
- data/lib/stattleship/params/basketball_injuries_params.rb +6 -0
- data/lib/stattleship/params/basketball_penalties_params.rb +6 -0
- data/lib/stattleship/params/basketball_players_params.rb +6 -0
- data/lib/stattleship/params/basketball_scoring_plays_params.rb +6 -0
- data/lib/stattleship/params/basketball_stat_leaders_params.rb +6 -0
- data/lib/stattleship/params/basketball_stats_params.rb +6 -0
- data/lib/stattleship/params/basketball_team_game_logs_params.rb +6 -0
- data/lib/stattleship/params/basketball_team_outcome_streaks_params.rb +9 -0
- data/lib/stattleship/params/basketball_team_stats_params.rb +10 -0
- data/lib/stattleship/params/basketball_teams_params.rb +6 -0
- data/lib/stattleship/params/basketball_top_stats_params.rb +6 -0
- data/lib/stattleship/params/basketball_total_player_stat_params.rb +6 -0
- data/lib/stattleship/params/basketball_total_team_stat_params.rb +11 -0
- data/lib/stattleship/params/feats_params.rb +23 -0
- data/lib/stattleship/params/football_feats_params.rb +6 -0
- data/lib/stattleship/params/football_game_logs_params.rb +11 -0
- data/lib/stattleship/params/football_games_params.rb +6 -0
- data/lib/stattleship/params/football_injuries_params.rb +6 -0
- data/lib/stattleship/params/football_penalties_params.rb +6 -0
- data/lib/stattleship/params/football_players_params.rb +6 -0
- data/lib/stattleship/params/football_scoring_plays_params.rb +6 -0
- data/lib/stattleship/params/football_stat_leaders_params.rb +6 -0
- data/lib/stattleship/params/football_stats_params.rb +6 -0
- data/lib/stattleship/params/football_team_game_logs_params.rb +6 -0
- data/lib/stattleship/params/football_team_outcome_streaks_params.rb +9 -0
- data/lib/stattleship/params/football_team_stats_params.rb +10 -0
- data/lib/stattleship/params/football_teams_params.rb +6 -0
- data/lib/stattleship/params/football_top_stats_params.rb +6 -0
- data/lib/stattleship/params/football_total_player_stat_params.rb +6 -0
- data/lib/stattleship/params/football_total_team_stat_params.rb +11 -0
- data/lib/stattleship/params/game_logs_params.rb +13 -0
- data/lib/stattleship/params/game_time_params.rb +17 -0
- data/lib/stattleship/params/games_params.rb +13 -0
- data/lib/stattleship/params/hockey_feats_params.rb +6 -0
- data/lib/stattleship/params/hockey_game_logs_params.rb +6 -0
- data/lib/stattleship/params/hockey_games_params.rb +6 -0
- data/lib/stattleship/params/hockey_injuries_params.rb +6 -0
- data/lib/stattleship/params/hockey_penalties_params.rb +6 -0
- data/lib/stattleship/params/hockey_players_params.rb +6 -0
- data/lib/stattleship/params/hockey_scoring_plays_params.rb +6 -0
- data/lib/stattleship/params/hockey_stat_leaders_params.rb +6 -0
- data/lib/stattleship/params/hockey_stats_params.rb +6 -0
- data/lib/stattleship/params/hockey_team_game_logs_params.rb +6 -0
- data/lib/stattleship/params/hockey_team_outcome_streaks_params.rb +9 -0
- data/lib/stattleship/params/hockey_team_stats_params.rb +10 -0
- data/lib/stattleship/params/hockey_teams_params.rb +6 -0
- data/lib/stattleship/params/hockey_top_stats_params.rb +6 -0
- data/lib/stattleship/params/hockey_total_player_stat_params.rb +6 -0
- data/lib/stattleship/params/hockey_total_team_stat_params.rb +11 -0
- data/lib/stattleship/params/injuries_params.rb +11 -0
- data/lib/stattleship/params/penalties_params.rb +11 -0
- data/lib/stattleship/params/players_params.rb +12 -0
- data/lib/stattleship/params/query_params.rb +50 -0
- data/lib/stattleship/params/rankings_params.rb +15 -0
- data/lib/stattleship/params/scoring_plays_params.rb +12 -0
- data/lib/stattleship/params/stat_leaders_params.rb +17 -0
- data/lib/stattleship/params/stats_params.rb +17 -0
- data/lib/stattleship/params/team_game_logs_params.rb +12 -0
- data/lib/stattleship/params/team_outcome_streaks_params.rb +24 -0
- data/lib/stattleship/params/teams_params.rb +9 -0
- data/lib/stattleship/params/top_stats_params.rb +17 -0
- data/lib/stattleship/params/total_player_stat_params.rb +17 -0
- data/lib/stattleship/params/total_team_stat_params.rb +18 -0
- data/lib/stattleship/penalties.rb +26 -0
- data/lib/stattleship/players.rb +26 -0
- data/lib/stattleship/rankings.rb +51 -0
- data/lib/stattleship/scoring_plays.rb +30 -0
- data/lib/stattleship/stat_leaders.rb +43 -0
- data/lib/stattleship/stats.rb +76 -0
- data/lib/stattleship/team_game_logs.rb +90 -0
- data/lib/stattleship/team_outcome_streaks.rb +28 -0
- data/lib/stattleship/teams.rb +20 -0
- data/lib/stattleship/top_stats.rb +58 -0
- data/lib/stattleship/total_player_stat.rb +37 -0
- data/lib/stattleship/total_team_stat.rb +30 -0
- data/lib/stattleship/validators.rb +33 -0
- data/lib/stattleship/validators/base_validator.rb +117 -0
- data/lib/stattleship/validators/birth_date_validator.rb +9 -0
- data/lib/stattleship/validators/current_validator.rb +9 -0
- data/lib/stattleship/validators/feat_validator.rb +9 -0
- data/lib/stattleship/validators/game_id_validator.rb +9 -0
- data/lib/stattleship/validators/interval_type_validator.rb +9 -0
- data/lib/stattleship/validators/level_up_validator.rb +9 -0
- data/lib/stattleship/validators/level_validator.rb +16 -0
- data/lib/stattleship/validators/on_validator.rb +9 -0
- data/lib/stattleship/validators/outcome_validator.rb +9 -0
- data/lib/stattleship/validators/page_validator.rb +9 -0
- data/lib/stattleship/validators/penalty_validator.rb +9 -0
- data/lib/stattleship/validators/per_page_validator.rb +9 -0
- data/lib/stattleship/validators/place_validator.rb +9 -0
- data/lib/stattleship/validators/player_id_validator.rb +9 -0
- data/lib/stattleship/validators/rank_validator.rb +9 -0
- data/lib/stattleship/validators/ranked_validator.rb +9 -0
- data/lib/stattleship/validators/ranking_validator.rb +9 -0
- data/lib/stattleship/validators/scoring_method_validator.rb +9 -0
- data/lib/stattleship/validators/scoring_type_validator.rb +9 -0
- data/lib/stattleship/validators/season_id_validator.rb +9 -0
- data/lib/stattleship/validators/since_validator.rb +9 -0
- data/lib/stattleship/validators/stat_validator.rb +23 -0
- data/lib/stattleship/validators/status_validator.rb +16 -0
- data/lib/stattleship/validators/streak_length_validator.rb +9 -0
- data/lib/stattleship/validators/team_id_validator.rb +9 -0
- data/lib/stattleship/validators/type_validator.rb +9 -0
- data/lib/stattleship/validators/week_validator.rb +9 -0
- data/lib/stattleship/version.rb +5 -0
- data/sample.env +1 -0
- data/stattleship-ruby.gemspec +33 -0
- metadata +503 -0
@@ -0,0 +1,150 @@
|
|
1
|
+
module Stattleship
|
2
|
+
class Feat < OpenStruct
|
3
|
+
def subject_name
|
4
|
+
subject.name
|
5
|
+
end
|
6
|
+
|
7
|
+
def subject
|
8
|
+
player || team
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_sentence
|
12
|
+
sentence_vs_on
|
13
|
+
end
|
14
|
+
|
15
|
+
def dump
|
16
|
+
{
|
17
|
+
accomplished_vs: accomplished_vs,
|
18
|
+
accomplishment: accomplishment,
|
19
|
+
actual: actual,
|
20
|
+
category: category,
|
21
|
+
description: description,
|
22
|
+
game_id: game_id,
|
23
|
+
game_slug: game_slug,
|
24
|
+
humanized_stat_type: humanized_stat_type,
|
25
|
+
level: level,
|
26
|
+
level_numeric: level_numeric,
|
27
|
+
name: name,
|
28
|
+
on: on,
|
29
|
+
opponent_abbrev: opponent_abbrev,
|
30
|
+
opponent_location: opponent_location,
|
31
|
+
opponent_name: opponent_name,
|
32
|
+
opponent_nickname: opponent_nickname,
|
33
|
+
opponent_slug: opponent_slug,
|
34
|
+
player_id: player_id,
|
35
|
+
player_slug: player_slug,
|
36
|
+
sentence: sentence,
|
37
|
+
sentence_on: sentence_on,
|
38
|
+
sentence_vs: sentence_vs,
|
39
|
+
sentence_vs_on: sentence_vs_on,
|
40
|
+
subject: subject.dump,
|
41
|
+
subject_id: subject_id,
|
42
|
+
subject_name: subject_name,
|
43
|
+
subject_slug: subject_slug,
|
44
|
+
subject_team_abbrev: subject_team_abbrev,
|
45
|
+
subject_team_location: subject_team_location,
|
46
|
+
subject_team_name: subject_team_name,
|
47
|
+
subject_team_nickname: subject_team_nickname,
|
48
|
+
subject_team_slug: subject_team_slug,
|
49
|
+
subject_type: subject_type,
|
50
|
+
team_id: team_id,
|
51
|
+
team_slug: team_slug,
|
52
|
+
title: title,
|
53
|
+
verb: verb,
|
54
|
+
vs: vs,
|
55
|
+
}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
class Feats < Stattleship::Endpoint
|
60
|
+
def populate
|
61
|
+
feats.each do |feat|
|
62
|
+
populate_games(feat)
|
63
|
+
|
64
|
+
games.each do |game|
|
65
|
+
populate_game(game)
|
66
|
+
end
|
67
|
+
|
68
|
+
populate_teams(feat)
|
69
|
+
|
70
|
+
populate_players(feat)
|
71
|
+
populate_player(feat.player)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
module FeatsRepresenter
|
77
|
+
include Roar::JSON
|
78
|
+
include Roar::Coercion
|
79
|
+
include Stattleship::Models
|
80
|
+
|
81
|
+
collection :feats, class: Stattleship::Feat do
|
82
|
+
property :accomplished_vs
|
83
|
+
property :accomplishment
|
84
|
+
property :actual, type: BigDecimal
|
85
|
+
property :category
|
86
|
+
property :description
|
87
|
+
property :game_id
|
88
|
+
property :game_slug
|
89
|
+
property :humanized_stat_type
|
90
|
+
property :level
|
91
|
+
property :level_numeric, type: Integer
|
92
|
+
property :name
|
93
|
+
property :on
|
94
|
+
property :opponent_abbrev
|
95
|
+
property :opponent_location
|
96
|
+
property :opponent_name
|
97
|
+
property :opponent_nickname
|
98
|
+
property :opponent_slug
|
99
|
+
property :player_id
|
100
|
+
property :player_slug
|
101
|
+
property :sentence
|
102
|
+
property :sentence_on
|
103
|
+
property :sentence_vs
|
104
|
+
property :sentence_vs_on
|
105
|
+
property :subject_id
|
106
|
+
property :subject_name
|
107
|
+
property :subject_team_name
|
108
|
+
property :subject_team_abbrev
|
109
|
+
property :subject_team_location
|
110
|
+
property :subject_team_nickname
|
111
|
+
property :subject_team_slug
|
112
|
+
property :subject_type
|
113
|
+
property :subject_slug
|
114
|
+
property :title
|
115
|
+
property :team_id
|
116
|
+
property :team_slug
|
117
|
+
property :verb
|
118
|
+
property :vs
|
119
|
+
property :league_id
|
120
|
+
property :season_id
|
121
|
+
end
|
122
|
+
|
123
|
+
collection :away_teams, extend: TeamRepresenter,
|
124
|
+
class: Team
|
125
|
+
|
126
|
+
collection :home_teams, extend: TeamRepresenter,
|
127
|
+
class: Team
|
128
|
+
|
129
|
+
collection :winning_teams, extend: TeamRepresenter,
|
130
|
+
class: Team
|
131
|
+
|
132
|
+
collection :games, extend: GameRepresenter,
|
133
|
+
class: Game
|
134
|
+
|
135
|
+
collection :leagues, extend: LeagueRepresenter,
|
136
|
+
class: League
|
137
|
+
|
138
|
+
collection :seasons, extend: SeasonRepresenter,
|
139
|
+
class: Season
|
140
|
+
|
141
|
+
collection :venues, extend: VenueRepresenter,
|
142
|
+
class: Venue
|
143
|
+
|
144
|
+
collection :players, extend: PlayerRepresenter,
|
145
|
+
class: Player
|
146
|
+
|
147
|
+
collection :teams, extend: TeamRepresenter,
|
148
|
+
class: Team
|
149
|
+
end
|
150
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Stattleship
|
2
|
+
class FootballFeats < Stattleship::Feats
|
3
|
+
FOOTBALL_FEATS = 'football/nfl/feats'.freeze
|
4
|
+
|
5
|
+
def self.fetch(params:)
|
6
|
+
super(path: FOOTBALL_FEATS,
|
7
|
+
params: params)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module FootballFeatsRepresenter
|
12
|
+
include Roar::JSON
|
13
|
+
include FeatsRepresenter
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,255 @@
|
|
1
|
+
module Stattleship
|
2
|
+
class FootballGameLog < Stattleship::GameLog
|
3
|
+
def stats
|
4
|
+
[
|
5
|
+
{ passer_rating: passer_rating },
|
6
|
+
{ tackles_solo: tackles_solo },
|
7
|
+
{ tackles_assists: tackles_assists },
|
8
|
+
{ sacks_total: sacks_total },
|
9
|
+
{ sacks_yards: sacks_yards },
|
10
|
+
{ passes_defensed: passes_defensed },
|
11
|
+
{ interceptions_total: interceptions_total },
|
12
|
+
{ interceptions_touchdown: interceptions_touchdown },
|
13
|
+
{ fumbles_committed: fumbles_committed },
|
14
|
+
{ passes_completions: passes_completions },
|
15
|
+
{ passes_yards_gross: passes_yards_gross },
|
16
|
+
{ passes_touchdowns: passes_touchdowns },
|
17
|
+
{ passes_interceptions: passes_interceptions },
|
18
|
+
{ receptions_total: receptions_total },
|
19
|
+
{ receptions_yards: receptions_yards },
|
20
|
+
{ receptions_touchdowns: receptions_touchdowns },
|
21
|
+
{ receptions_looks: receptions_looks },
|
22
|
+
{ rushes_attempts: rushes_attempts },
|
23
|
+
{ rushes_yards: rushes_yards },
|
24
|
+
{ rushes_touchdowns: rushes_touchdowns },
|
25
|
+
{ field_goals_made: field_goals_made },
|
26
|
+
{ extra_points_made: extra_points_made },
|
27
|
+
{ punts_total: punts_total },
|
28
|
+
{ points: points },
|
29
|
+
].map { |stat| build_statline(stat: stat) }.compact
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_sentence
|
33
|
+
"#{player_name} #{stats.join(', ')} (#{game.name})"
|
34
|
+
end
|
35
|
+
|
36
|
+
def build_statline(stat:)
|
37
|
+
name = stat.keys.first
|
38
|
+
value = stat.values.first
|
39
|
+
if value && value != 0
|
40
|
+
"#{StatFormatter.format(value: value)} #{stat_abbreviation(stat_name: name)}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def stat_abbreviation(stat_name:)
|
45
|
+
case stat_name.to_s
|
46
|
+
when 'passer_rating'
|
47
|
+
'RTG'
|
48
|
+
when 'tackles_solo'
|
49
|
+
'T'
|
50
|
+
when 'tackles_assists'
|
51
|
+
'TA'
|
52
|
+
when 'sacks_total'
|
53
|
+
'SCKS'
|
54
|
+
when 'sacks_yards'
|
55
|
+
'SYDS'
|
56
|
+
when 'passes_defensed'
|
57
|
+
'PD'
|
58
|
+
when 'interceptions_total'
|
59
|
+
'INT'
|
60
|
+
when 'interceptions_touchdown'
|
61
|
+
'INT TD'
|
62
|
+
when 'fumbles_committed'
|
63
|
+
'F'
|
64
|
+
when 'passes_completions'
|
65
|
+
'CMP'
|
66
|
+
when 'passes_yards_gross'
|
67
|
+
'YDS'
|
68
|
+
when 'passes_touchdowns'
|
69
|
+
'TD'
|
70
|
+
when 'passes_interceptions'
|
71
|
+
'INT'
|
72
|
+
when 'receptions_total'
|
73
|
+
'R'
|
74
|
+
when 'receptions_yards'
|
75
|
+
'RYDS'
|
76
|
+
when 'receptions_touchdowns'
|
77
|
+
'RTD'
|
78
|
+
when 'receptions_looks'
|
79
|
+
'L'
|
80
|
+
when 'rushes_attempts'
|
81
|
+
'R'
|
82
|
+
when 'rushes_yards'
|
83
|
+
'RYDS'
|
84
|
+
when 'rushes_touchdowns'
|
85
|
+
'RTD'
|
86
|
+
when 'field_goals_made'
|
87
|
+
'FG'
|
88
|
+
when 'extra_points_made'
|
89
|
+
'XP'
|
90
|
+
when 'punts_total'
|
91
|
+
'punts_total'
|
92
|
+
when 'points'
|
93
|
+
'PTS'
|
94
|
+
else
|
95
|
+
''
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
class FootballGameLogs < Stattleship::GameLogs
|
101
|
+
FOOTBALL_GAME_LOGS = 'football/nfl/game_logs'.freeze
|
102
|
+
|
103
|
+
def self.fetch(params:)
|
104
|
+
super(path: FOOTBALL_GAME_LOGS,
|
105
|
+
params: params)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
module FootballGameLogsRepresenter
|
110
|
+
include Roar::JSON
|
111
|
+
include Roar::Coercion
|
112
|
+
include Stattleship::GameLogsRepresenter
|
113
|
+
include Virtus.model
|
114
|
+
|
115
|
+
collection :game_logs, class: Stattleship::FootballGameLog do
|
116
|
+
|
117
|
+
[
|
118
|
+
:away_team_outcome,
|
119
|
+
:home_team_outcome,
|
120
|
+
:team_outcome,
|
121
|
+
:opponent_outcome,
|
122
|
+
].each do |attribute|
|
123
|
+
property attribute
|
124
|
+
end
|
125
|
+
|
126
|
+
[
|
127
|
+
:passes_percentage,
|
128
|
+
:receptions_average_yards_per,
|
129
|
+
:passer_rating,
|
130
|
+
:rushing_average_yards_per,
|
131
|
+
].each do |attribute|
|
132
|
+
property attribute, type: BigDecimal
|
133
|
+
end
|
134
|
+
|
135
|
+
[
|
136
|
+
:game_played,
|
137
|
+
:game_started,
|
138
|
+
:home_team_score,
|
139
|
+
:away_team_score,
|
140
|
+
:team_score,
|
141
|
+
:opponent_score,
|
142
|
+
:tackles_solo,
|
143
|
+
:tackles_assists,
|
144
|
+
:sacks_total,
|
145
|
+
:sacks_yards,
|
146
|
+
:passes_defensed,
|
147
|
+
:interceptions_total,
|
148
|
+
:interceptions_yards,
|
149
|
+
:interceptions_longest,
|
150
|
+
:interceptions_touchdown,
|
151
|
+
:defense_misc_assisted_tackles,
|
152
|
+
:defense_misc_solo_tackles,
|
153
|
+
:defense_tackles,
|
154
|
+
:defense_tackles_for_loss,
|
155
|
+
:defense_tackles_for_loss_yards,
|
156
|
+
:interceptions_returned_touchdowns_longest_yards,
|
157
|
+
:safeties,
|
158
|
+
:fumbles_forced,
|
159
|
+
:fumbles_committed,
|
160
|
+
:fumbles_lost,
|
161
|
+
:fumbles_own_recovered,
|
162
|
+
:fumbles_opposing_recovered,
|
163
|
+
:fumbles_own_touchdowns,
|
164
|
+
:fumbles_opposing_touchdowns,
|
165
|
+
:fumbles_recovered_touchdowns_longest_yards,
|
166
|
+
:defense_fumble_recoveries,
|
167
|
+
:defense_miscellaneous_fumble_recoveries,
|
168
|
+
:passes_completions,
|
169
|
+
:passes_yards_gross,
|
170
|
+
:passes_touchdowns,
|
171
|
+
:passes_interceptions,
|
172
|
+
:passes_longest,
|
173
|
+
:receptions_total,
|
174
|
+
:receptions_yards,
|
175
|
+
:receptions_touchdowns,
|
176
|
+
:receptions_looks,
|
177
|
+
:receptions_longest,
|
178
|
+
:passing_2pt_conversions_succeeded,
|
179
|
+
:passing_touchdowns_longest_yards,
|
180
|
+
:receiving_2pt_conversions_succeeded,
|
181
|
+
:receiving_touchdowns_longest_yards,
|
182
|
+
:rushes_attempts,
|
183
|
+
:rushes_yards,
|
184
|
+
:rushes_touchdowns,
|
185
|
+
:rushes_longest,
|
186
|
+
:rushing_2pt_conversions_succeeded,
|
187
|
+
:rushing_gross_yards,
|
188
|
+
:rushing_lost_yards,
|
189
|
+
:rushing_touchdowns_longest_yards,
|
190
|
+
:sacks_against_total,
|
191
|
+
:sacks_against_yards,
|
192
|
+
:extra_points_attempts,
|
193
|
+
:extra_points_made,
|
194
|
+
:field_goal_attempts,
|
195
|
+
:field_goals_made,
|
196
|
+
:field_goals_missed,
|
197
|
+
:field_goals_blocked,
|
198
|
+
:field_goals_attempted_against,
|
199
|
+
:field_goals_succeeded_against,
|
200
|
+
:field_goals_succeeded_longest_yards,
|
201
|
+
:field_goals_succeeded_yards,
|
202
|
+
:total_touchdowns,
|
203
|
+
:penalty_yards,
|
204
|
+
:points,
|
205
|
+
:punts_total,
|
206
|
+
:punts_yards_gross,
|
207
|
+
:punts_inside_twenty,
|
208
|
+
:punts_longest,
|
209
|
+
:touchbacks_total,
|
210
|
+
:punts_blocked,
|
211
|
+
:defense_special_teams_assisted_tackles,
|
212
|
+
:defense_special_teams_fumble_recoveries,
|
213
|
+
:defense_special_teams_solo_tackles,
|
214
|
+
:defense_special_teams_tackles,
|
215
|
+
:defense_special_teams_kicks_blocked,
|
216
|
+
:kicking_singles,
|
217
|
+
:kickoff_longest_yards,
|
218
|
+
:kickoff_return_faircatches,
|
219
|
+
:kickoff_return_longest_yards,
|
220
|
+
:kickoff_return_touchdowns,
|
221
|
+
:kickoff_return_touchdowns_longest_yards,
|
222
|
+
:kickoff_return_yards,
|
223
|
+
:kickoff_returns,
|
224
|
+
:kickoff_singles,
|
225
|
+
:kickoff_yards,
|
226
|
+
:kickoffs,
|
227
|
+
:punt_return_faircatches,
|
228
|
+
:punt_return_longest_yards,
|
229
|
+
:punt_return_touchdowns,
|
230
|
+
:punt_return_touchdowns_longest_yards,
|
231
|
+
:punt_return_yards,
|
232
|
+
:punt_returns,
|
233
|
+
:punting_net_yards,
|
234
|
+
:punting_singles,
|
235
|
+
].each do |attribute|
|
236
|
+
property attribute
|
237
|
+
end
|
238
|
+
|
239
|
+
[
|
240
|
+
:is_home_team,
|
241
|
+
:is_away_team,
|
242
|
+
].each do |attribute|
|
243
|
+
property attribute, type: Boolean, default: false
|
244
|
+
end
|
245
|
+
|
246
|
+
[
|
247
|
+
:player_id,
|
248
|
+
:game_id,
|
249
|
+
:team_id
|
250
|
+
].each do |relationship|
|
251
|
+
property relationship
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Stattleship
|
2
|
+
class FootballGames < Stattleship::Games
|
3
|
+
FOOTBALL_GAMES = 'football/nfl/games'.freeze
|
4
|
+
|
5
|
+
def self.fetch(params:)
|
6
|
+
super(path: FOOTBALL_GAMES,
|
7
|
+
params: params)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module FootballGamesRepresenter
|
12
|
+
include Roar::JSON
|
13
|
+
include GamesRepresenter
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Stattleship
|
2
|
+
class FootballInjuries < Stattleship::Injuries
|
3
|
+
FOOTBALL_INJURIES = 'football/nfl/injuries'.freeze
|
4
|
+
|
5
|
+
def self.fetch(params:)
|
6
|
+
super(path: FOOTBALL_INJURIES,
|
7
|
+
params: params)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module FootballInjuriesRepresenter
|
12
|
+
include Roar::JSON
|
13
|
+
include InjuriesRepresenter
|
14
|
+
end
|
15
|
+
end
|