stattleship-ruby 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,201 @@
|
|
|
1
|
+
module Stattleship
|
|
2
|
+
module Models
|
|
3
|
+
class ScoringPlay < OpenStruct
|
|
4
|
+
def away_team
|
|
5
|
+
game.away_team
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def home_team
|
|
9
|
+
game.home_team
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def winning_team
|
|
13
|
+
game.winning_team
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def away_team_name
|
|
17
|
+
away_team.name
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def home_team_name
|
|
21
|
+
home_team.name
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def winning_team_name
|
|
25
|
+
winning_team.name
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def city
|
|
29
|
+
venue.city
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def league_name
|
|
33
|
+
league.name
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def league_abbreviation
|
|
37
|
+
league.abbreviation
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def player_name
|
|
41
|
+
# player.name
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def opponent_name
|
|
45
|
+
opponent.name
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def opponent_full_name
|
|
49
|
+
opponent.full_name
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def scoreline
|
|
53
|
+
game.scoreline
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def team_name
|
|
57
|
+
team.name
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def team_full_name
|
|
61
|
+
team.full_name
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def venue
|
|
65
|
+
game.venue
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def venue_name
|
|
69
|
+
venue.name
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def scorers
|
|
73
|
+
return unless scoring_players
|
|
74
|
+
|
|
75
|
+
scoring_players.select do |scoring_player|
|
|
76
|
+
scoring_player.role == 'scorer'
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def scorer
|
|
81
|
+
scorers.first if scorers
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def scorer_name
|
|
85
|
+
if scorer
|
|
86
|
+
scorer.player_name
|
|
87
|
+
else
|
|
88
|
+
''
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def assists
|
|
93
|
+
return unless scoring_players
|
|
94
|
+
|
|
95
|
+
scoring_players.select do |scoring_player|
|
|
96
|
+
scoring_player.role == 'assist'
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def assist_names
|
|
101
|
+
if assists && assists.count > 0
|
|
102
|
+
assists.map(&:player_name).join(', ')
|
|
103
|
+
else
|
|
104
|
+
'Unassisted'
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def period_time
|
|
109
|
+
Time.at(period_seconds).utc.strftime('%M:%S')
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def period_abbreviation
|
|
113
|
+
if game.hockey?
|
|
114
|
+
"P"
|
|
115
|
+
else
|
|
116
|
+
"Q"
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def period
|
|
121
|
+
"#{period_number}#{period_abbreviation}"
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def at
|
|
125
|
+
"#{period_time} of #{period}"
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def scoring_player_names
|
|
129
|
+
if scoring_players
|
|
130
|
+
scoring_players.map(&:player_name).join(', ')
|
|
131
|
+
else
|
|
132
|
+
''
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def scoring_player_role_names
|
|
137
|
+
if scoring_players
|
|
138
|
+
scoring_players.map(&:name).join(', ')
|
|
139
|
+
else
|
|
140
|
+
''
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def scoring_players_info
|
|
145
|
+
if scoring_players
|
|
146
|
+
player_names = scoring_players.map(&:player_name)
|
|
147
|
+
role_names = scoring_players.map(&:name)
|
|
148
|
+
player_names.zip(role_names).flatten.compact.join(', ')
|
|
149
|
+
else
|
|
150
|
+
''
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def vs
|
|
155
|
+
if game
|
|
156
|
+
"vs #{opponent_name} #{game.short_date}"
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def to_sentence
|
|
161
|
+
if game.hockey?
|
|
162
|
+
"#{scorer_name} (#{assist_names}) - #{at} - #{vs}"
|
|
163
|
+
elsif game.football?
|
|
164
|
+
"#{period_number} QTR #{period_time} - #{points} points - #{yards} yards - #{scoring_players_info} - #{vs}"
|
|
165
|
+
else
|
|
166
|
+
''
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
module ScoringPlayRepresenter
|
|
172
|
+
include Roar::JSON
|
|
173
|
+
include Roar::Coercion
|
|
174
|
+
include Stattleship::Models
|
|
175
|
+
include Virtus.model
|
|
176
|
+
|
|
177
|
+
property :id
|
|
178
|
+
property :game_id
|
|
179
|
+
property :opponent_id
|
|
180
|
+
property :team_id
|
|
181
|
+
|
|
182
|
+
property :conversion
|
|
183
|
+
property :conversion_points, type: Integer
|
|
184
|
+
property :empty_net, type: Boolean, default: false
|
|
185
|
+
property :name
|
|
186
|
+
property :period_number, type: Integer
|
|
187
|
+
property :period_seconds, type: Integer
|
|
188
|
+
property :points, type: Integer
|
|
189
|
+
property :scored_at, type: DateTime
|
|
190
|
+
property :scoring_conversion
|
|
191
|
+
property :scoring_conversion_points, type: Integer
|
|
192
|
+
property :scoring_how
|
|
193
|
+
property :scoring_method
|
|
194
|
+
property :scoring_type
|
|
195
|
+
property :time_code
|
|
196
|
+
property :yards, type: Integer
|
|
197
|
+
|
|
198
|
+
collection :scoring_player_ids
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Stattleship
|
|
2
|
+
module Models
|
|
3
|
+
class ScoringPlayer < OpenStruct
|
|
4
|
+
def player_name
|
|
5
|
+
player.name
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
module ScoringPlayerRepresenter
|
|
10
|
+
include Roar::JSON
|
|
11
|
+
include Roar::Coercion
|
|
12
|
+
include Virtus.model
|
|
13
|
+
|
|
14
|
+
property :id
|
|
15
|
+
property :player_id
|
|
16
|
+
property :scoring_play_id
|
|
17
|
+
|
|
18
|
+
property :name
|
|
19
|
+
property :role
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Stattleship
|
|
2
|
+
module Models
|
|
3
|
+
class Season < OpenStruct
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
module SeasonRepresenter
|
|
7
|
+
include Roar::JSON
|
|
8
|
+
include Roar::Coercion
|
|
9
|
+
|
|
10
|
+
property :ends_on, type: Date
|
|
11
|
+
property :id
|
|
12
|
+
property :league_id
|
|
13
|
+
property :name
|
|
14
|
+
property :slug
|
|
15
|
+
property :starts_on, type: Date
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
module Stattleship
|
|
2
|
+
module Models
|
|
3
|
+
class Team < OpenStruct
|
|
4
|
+
def full_name
|
|
5
|
+
"#{location} #{nickname}"
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def title
|
|
9
|
+
"#{full_name} - #{league_abbreviation}"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def league_abbreviation
|
|
13
|
+
if league
|
|
14
|
+
league.abbreviation
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def color_css
|
|
19
|
+
"##{color}"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def colors_css
|
|
23
|
+
if colors
|
|
24
|
+
colors.map { |c| "##{c}"}
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def hashtag_with_hash
|
|
29
|
+
"##{hashtag}"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def hashtags_with_hash
|
|
33
|
+
if hashtags
|
|
34
|
+
hashtags.map { |c| "##{c}"}
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def dump
|
|
39
|
+
{
|
|
40
|
+
full_name: full_name,
|
|
41
|
+
title: title,
|
|
42
|
+
color: color,
|
|
43
|
+
colors: colors,
|
|
44
|
+
hashtag: hashtag,
|
|
45
|
+
hashtags: hashtags,
|
|
46
|
+
league_abbreviation: league_abbreviation,
|
|
47
|
+
location: location,
|
|
48
|
+
latitude: latitude,
|
|
49
|
+
longitude: longitude,
|
|
50
|
+
name: name,
|
|
51
|
+
nickname: nickname,
|
|
52
|
+
slug: slug,
|
|
53
|
+
}
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def coordinates
|
|
57
|
+
[latitude, longitude]
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
module TeamRepresenter
|
|
62
|
+
include Roar::JSON
|
|
63
|
+
|
|
64
|
+
property :id
|
|
65
|
+
property :color
|
|
66
|
+
collection :colors
|
|
67
|
+
property :hashtag
|
|
68
|
+
collection :hashtags
|
|
69
|
+
property :league_id
|
|
70
|
+
property :location
|
|
71
|
+
property :latitude, type: Float
|
|
72
|
+
property :longitude, type: Float
|
|
73
|
+
property :name
|
|
74
|
+
property :nickname
|
|
75
|
+
property :slug
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
module Stattleship
|
|
2
|
+
module Models
|
|
3
|
+
class TeamOutcomeStreak < OpenStruct
|
|
4
|
+
def current?
|
|
5
|
+
current
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def league_name
|
|
9
|
+
league.name
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def league_abbreviation
|
|
13
|
+
league.abbreviation
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def team_location
|
|
17
|
+
team.location
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def team_name
|
|
21
|
+
team.name
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def team_nickname
|
|
25
|
+
team.nickname
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def team_full_name
|
|
29
|
+
team.full_name
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def to_sentence
|
|
33
|
+
if current
|
|
34
|
+
"#{team_full_name} are currently on a #{streak_length} game #{outcome_participle} streak starting #{started_on_short_date}"
|
|
35
|
+
else
|
|
36
|
+
"#{team_full_name} had a #{streak_length} game #{outcome_participle} streak between #{started_on_short_date} and #{ended_on_short_date}"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def to_rank
|
|
41
|
+
"#{team_full_name} #{rank.ordinalize} streak of the season is a #{streak_length} game #{outcome} streak between #{started_on_short_date} and #{ended_on_short_date}."
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def outcome_participle
|
|
45
|
+
if win?
|
|
46
|
+
'winning'
|
|
47
|
+
else
|
|
48
|
+
'losing'
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def loss?
|
|
53
|
+
outcome == 'loss'
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def win?
|
|
57
|
+
outcome == 'win'
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def started_on_short_date
|
|
61
|
+
started_on.to_datetime.strftime('%b %d')
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def ended_on_short_date
|
|
65
|
+
ended_on.to_datetime.strftime('%b %d')
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
module TeamOutcomeStreakRepresenter
|
|
70
|
+
include Roar::JSON
|
|
71
|
+
include Roar::Coercion
|
|
72
|
+
include Virtus.model
|
|
73
|
+
|
|
74
|
+
property :league_id
|
|
75
|
+
property :season_id
|
|
76
|
+
property :team_id
|
|
77
|
+
property :current, type: Boolean, default: false
|
|
78
|
+
property :ended_on, type: Date
|
|
79
|
+
property :game_number, type: Integer
|
|
80
|
+
property :outcome
|
|
81
|
+
property :rank, type: Integer
|
|
82
|
+
property :started_on, type: Date
|
|
83
|
+
property :streak, type: Integer
|
|
84
|
+
property :streak_length, type: Integer
|
|
85
|
+
property :streak_length_in_days, type: Integer
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Stattleship
|
|
2
|
+
module Models
|
|
3
|
+
class Venue < OpenStruct
|
|
4
|
+
def coordinates
|
|
5
|
+
[latitude, longitude]
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def dump
|
|
9
|
+
to_h
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
module VenueRepresenter
|
|
14
|
+
include Roar::JSON
|
|
15
|
+
include Roar::Coercion
|
|
16
|
+
|
|
17
|
+
property :abbreviation
|
|
18
|
+
property :capacity, type: Integer
|
|
19
|
+
property :city
|
|
20
|
+
property :country
|
|
21
|
+
property :field_type
|
|
22
|
+
property :id
|
|
23
|
+
property :latitude, type: Float
|
|
24
|
+
property :longitude, type: Float
|
|
25
|
+
property :id
|
|
26
|
+
property :name
|
|
27
|
+
property :slug
|
|
28
|
+
property :state
|
|
29
|
+
property :time_zone
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
require 'stattleship/params/query_params'
|
|
2
|
+
require 'stattleship/params/game_time_params'
|
|
3
|
+
require 'stattleship/params/rankings_params'
|
|
4
|
+
|
|
5
|
+
require 'stattleship/params/feats_params'
|
|
6
|
+
require 'stattleship/params/basketball_feats_params'
|
|
7
|
+
require 'stattleship/params/football_feats_params'
|
|
8
|
+
require 'stattleship/params/hockey_feats_params'
|
|
9
|
+
require 'stattleship/params/baseball_feats_params'
|
|
10
|
+
|
|
11
|
+
require 'stattleship/params/game_logs_params'
|
|
12
|
+
require 'stattleship/params/basketball_game_logs_params'
|
|
13
|
+
require 'stattleship/params/football_game_logs_params'
|
|
14
|
+
require 'stattleship/params/hockey_game_logs_params'
|
|
15
|
+
require 'stattleship/params/baseball_game_logs_params'
|
|
16
|
+
|
|
17
|
+
require 'stattleship/params/games_params'
|
|
18
|
+
require 'stattleship/params/basketball_games_params'
|
|
19
|
+
require 'stattleship/params/football_games_params'
|
|
20
|
+
require 'stattleship/params/hockey_games_params'
|
|
21
|
+
require 'stattleship/params/baseball_games_params'
|
|
22
|
+
|
|
23
|
+
require 'stattleship/params/injuries_params'
|
|
24
|
+
require 'stattleship/params/basketball_injuries_params'
|
|
25
|
+
require 'stattleship/params/football_injuries_params'
|
|
26
|
+
require 'stattleship/params/hockey_injuries_params'
|
|
27
|
+
require 'stattleship/params/baseball_injuries_params'
|
|
28
|
+
|
|
29
|
+
require 'stattleship/params/penalties_params'
|
|
30
|
+
require 'stattleship/params/basketball_penalties_params'
|
|
31
|
+
require 'stattleship/params/football_penalties_params'
|
|
32
|
+
require 'stattleship/params/hockey_penalties_params'
|
|
33
|
+
require 'stattleship/params/baseball_penalties_params'
|
|
34
|
+
|
|
35
|
+
require 'stattleship/params/players_params'
|
|
36
|
+
require 'stattleship/params/basketball_players_params'
|
|
37
|
+
require 'stattleship/params/football_players_params'
|
|
38
|
+
require 'stattleship/params/hockey_players_params'
|
|
39
|
+
require 'stattleship/params/baseball_players_params'
|
|
40
|
+
|
|
41
|
+
require 'stattleship/params/scoring_plays_params'
|
|
42
|
+
require 'stattleship/params/basketball_scoring_plays_params'
|
|
43
|
+
require 'stattleship/params/football_scoring_plays_params'
|
|
44
|
+
require 'stattleship/params/hockey_scoring_plays_params'
|
|
45
|
+
require 'stattleship/params/baseball_scoring_plays_params'
|
|
46
|
+
|
|
47
|
+
require 'stattleship/params/stat_leaders_params'
|
|
48
|
+
require 'stattleship/params/basketball_stat_leaders_params'
|
|
49
|
+
require 'stattleship/params/football_stat_leaders_params'
|
|
50
|
+
require 'stattleship/params/hockey_stat_leaders_params'
|
|
51
|
+
require 'stattleship/params/baseball_stat_leaders_params'
|
|
52
|
+
|
|
53
|
+
require 'stattleship/params/stats_params'
|
|
54
|
+
require 'stattleship/params/basketball_stats_params'
|
|
55
|
+
require 'stattleship/params/basketball_team_stats_params'
|
|
56
|
+
require 'stattleship/params/football_stats_params'
|
|
57
|
+
require 'stattleship/params/football_team_stats_params'
|
|
58
|
+
require 'stattleship/params/hockey_stats_params'
|
|
59
|
+
require 'stattleship/params/baseball_stats_params'
|
|
60
|
+
require 'stattleship/params/hockey_team_stats_params'
|
|
61
|
+
require 'stattleship/params/baseball_team_stats_params'
|
|
62
|
+
|
|
63
|
+
require 'stattleship/params/teams_params'
|
|
64
|
+
require 'stattleship/params/basketball_teams_params'
|
|
65
|
+
require 'stattleship/params/football_teams_params'
|
|
66
|
+
require 'stattleship/params/hockey_teams_params'
|
|
67
|
+
require 'stattleship/params/baseball_teams_params'
|
|
68
|
+
|
|
69
|
+
require 'stattleship/params/team_game_logs_params'
|
|
70
|
+
require 'stattleship/params/basketball_team_game_logs_params'
|
|
71
|
+
require 'stattleship/params/football_team_game_logs_params'
|
|
72
|
+
require 'stattleship/params/hockey_team_game_logs_params'
|
|
73
|
+
require 'stattleship/params/baseball_team_game_logs_params'
|
|
74
|
+
|
|
75
|
+
require 'stattleship/params/team_outcome_streaks_params'
|
|
76
|
+
require 'stattleship/params/basketball_team_outcome_streaks_params'
|
|
77
|
+
require 'stattleship/params/football_team_outcome_streaks_params'
|
|
78
|
+
require 'stattleship/params/hockey_team_outcome_streaks_params'
|
|
79
|
+
require 'stattleship/params/baseball_team_outcome_streaks_params'
|
|
80
|
+
|
|
81
|
+
require 'stattleship/params/top_stats_params'
|
|
82
|
+
require 'stattleship/params/basketball_top_stats_params'
|
|
83
|
+
require 'stattleship/params/football_top_stats_params'
|
|
84
|
+
require 'stattleship/params/hockey_top_stats_params'
|
|
85
|
+
require 'stattleship/params/baseball_top_stats_params'
|
|
86
|
+
|
|
87
|
+
require 'stattleship/params/total_player_stat_params'
|
|
88
|
+
require 'stattleship/params/basketball_total_player_stat_params'
|
|
89
|
+
require 'stattleship/params/football_total_player_stat_params'
|
|
90
|
+
require 'stattleship/params/hockey_total_player_stat_params'
|
|
91
|
+
require 'stattleship/params/baseball_total_player_stat_params'
|
|
92
|
+
|
|
93
|
+
require 'stattleship/params/total_team_stat_params'
|
|
94
|
+
require 'stattleship/params/basketball_total_team_stat_params'
|
|
95
|
+
require 'stattleship/params/football_total_team_stat_params'
|
|
96
|
+
require 'stattleship/params/hockey_total_team_stat_params'
|
|
97
|
+
require 'stattleship/params/baseball_total_team_stat_params'
|
|
98
|
+
|
|
99
|
+
module Stattleship
|
|
100
|
+
module Params
|
|
101
|
+
end
|
|
102
|
+
end
|