ahl_scraper 0.2.0 → 0.3.0

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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/CHANGELOG.md +49 -0
  4. data/Gemfile +8 -8
  5. data/Gemfile.lock +46 -41
  6. data/ahl_scraper.gemspec +1 -1
  7. data/lib/ahl_scraper/fetchers/game_data_fetcher.rb +1 -1
  8. data/lib/ahl_scraper/fetchers/player_data_fetcher.rb +1 -1
  9. data/lib/ahl_scraper/fetchers/player_games/data_fetcher.rb +1 -1
  10. data/lib/ahl_scraper/fetchers/season_type_fetcher.rb +1 -2
  11. data/lib/ahl_scraper/fixed_games/1001050.json +18 -18
  12. data/lib/ahl_scraper/fixed_games/1003351.json +2728 -0
  13. data/lib/ahl_scraper/fixed_games/1018774.json +4 -4
  14. data/lib/ahl_scraper/fixed_games/1020527.json +8 -8
  15. data/lib/ahl_scraper/resources/game.rb +4 -3
  16. data/lib/ahl_scraper/resources/game_list_item.rb +13 -13
  17. data/lib/ahl_scraper/resources/games/info.rb +1 -1
  18. data/lib/ahl_scraper/resources/games/penalty.rb +2 -2
  19. data/lib/ahl_scraper/resources/games/team.rb +2 -2
  20. data/lib/ahl_scraper/resources/goalie_game_list_item.rb +2 -1
  21. data/lib/ahl_scraper/resources/player.rb +2 -2
  22. data/lib/ahl_scraper/resources/playoff_bracket.rb +5 -5
  23. data/lib/ahl_scraper/resources/playoff_brackets/round.rb +1 -1
  24. data/lib/ahl_scraper/resources/playoff_brackets/series.rb +60 -20
  25. data/lib/ahl_scraper/resources/roster_player.rb +1 -1
  26. data/lib/ahl_scraper/resources/season.rb +13 -8
  27. data/lib/ahl_scraper/resources/season_list_item.rb +2 -2
  28. data/lib/ahl_scraper/resources/seasons/team.rb +4 -3
  29. data/lib/ahl_scraper/resources/skater_game_list_item.rb +2 -2
  30. data/lib/ahl_scraper/resources/team_game_list_item.rb +2 -3
  31. data/lib/ahl_scraper/resources/team_list_item.rb +1 -1
  32. data/lib/ahl_scraper/services/games/create_skaters_service.rb +1 -1
  33. data/lib/ahl_scraper/services/games/on_ice_statlines_service.rb +1 -1
  34. data/lib/ahl_scraper/services/games/scoring_statlines_service.rb +29 -25
  35. data/lib/ahl_scraper/services/games/team_on_ice_goals_service.rb +1 -1
  36. data/lib/ahl_scraper/team_games.rb +3 -1
  37. data/lib/ahl_scraper/version.rb +1 -1
  38. metadata +5 -4
@@ -17,21 +17,7 @@ module AhlScraper
17
17
  a1_id = goal[:assists][0]&.dig(:id) && scoring_statlines[goal[:assists][0]&.dig(:id).to_s] ? goal[:assists][0]&.dig(:id).to_s : false # Make sure assist exists and does not belong to goalie
18
18
  a2_id = goal[:assists][1]&.dig(:id) && scoring_statlines[goal[:assists][1]&.dig(:id).to_s] ? goal[:assists][1]&.dig(:id).to_s : false # Make sure assist exists and does not belong to goalie
19
19
 
20
- add_points(goalscorer_id, a1_id, a2_id, "as")
21
- if goal[:properties][:isPenaltyShot].to_i.positive?
22
- scoring_statlines[goalscorer_id][:goals_ps] += 1
23
- elsif extra_skater?(goal, plus_player_count, minus_player_count)
24
- add_points(goalscorer_id, a1_id, a2_id, "ex")
25
- elsif goal[:properties][:isEmptyNet].to_i.positive?
26
- add_points(goalscorer_id, a1_id, a2_id, "en")
27
- elsif goal[:properties][:isPowerPlay].to_i.positive?
28
- add_points(goalscorer_id, a1_id, a2_id, "pp")
29
- elsif goal[:properties][:isShortHanded].to_i.positive?
30
- add_points(goalscorer_id, a1_id, a2_id, "sh")
31
- elsif plus_player_count == minus_player_count
32
- add_points(goalscorer_id, a1_id, a2_id, "ev")
33
- add_points(goalscorer_id, a1_id, a2_id, "5v5") if plus_player_count == 5 && minus_player_count == 5
34
- end
20
+ add_to_statline(goal, plus_player_count, minus_player_count, goalscorer_id, a1_id, a2_id)
35
21
  end
36
22
 
37
23
  scoring_statlines
@@ -39,6 +25,24 @@ module AhlScraper
39
25
 
40
26
  private
41
27
 
28
+ def add_to_statline(goal, plus_player_count, minus_player_count, goalscorer_id, a1_id, a2_id)
29
+ add_points(goalscorer_id, a1_id, a2_id, "as")
30
+ if goal[:properties][:isPenaltyShot].to_i.positive?
31
+ scoring_statlines[goalscorer_id][:goals_ps] += 1
32
+ elsif extra_skater?(goal, plus_player_count, minus_player_count)
33
+ add_points(goalscorer_id, a1_id, a2_id, "ex")
34
+ elsif goal[:properties][:isEmptyNet].to_i.positive?
35
+ add_points(goalscorer_id, a1_id, a2_id, "en")
36
+ elsif goal[:properties][:isPowerPlay].to_i.positive?
37
+ add_points(goalscorer_id, a1_id, a2_id, "pp")
38
+ elsif goal[:properties][:isShortHanded].to_i.positive?
39
+ add_points(goalscorer_id, a1_id, a2_id, "sh")
40
+ elsif plus_player_count == minus_player_count
41
+ add_points(goalscorer_id, a1_id, a2_id, "ev")
42
+ add_points(goalscorer_id, a1_id, a2_id, "5v5") if plus_player_count == 5 && minus_player_count == 5
43
+ end
44
+ end
45
+
42
46
  def scoring_statlines
43
47
  @scoring_statlines ||= @skater_ids.map { |s_id| [s_id.to_s, blank_statline] }.to_h
44
48
  end
@@ -49,50 +53,50 @@ module AhlScraper
49
53
  a1_as: 0,
50
54
  a2_as: 0,
51
55
  points_as: 0,
52
- primary_points_as: 0,
56
+ p1_as: 0,
53
57
  goals_ps: 0,
54
- primary_points_ps: 0,
58
+ p1_ps: 0,
55
59
  goals_ev: 0,
56
60
  a1_ev: 0,
57
61
  a2_ev: 0,
58
62
  points_ev: 0,
59
- primary_points_ev: 0,
63
+ p1_ev: 0,
60
64
  goals_5v5: 0,
61
65
  a1_5v5: 0,
62
66
  a2_5v5: 0,
63
67
  points_5v5: 0,
64
- primary_points_5v5: 0,
68
+ p1_5v5: 0,
65
69
  goals_pp: 0,
66
70
  a1_pp: 0,
67
71
  a2_pp: 0,
68
72
  points_pp: 0,
69
- primary_points_pp: 0,
73
+ p1_pp: 0,
70
74
  goals_sh: 0,
71
75
  a1_sh: 0,
72
76
  a2_sh: 0,
73
77
  points_sh: 0,
74
- primary_points_sh: 0,
78
+ p1_sh: 0,
75
79
  goals_ex: 0,
76
80
  a1_ex: 0,
77
81
  a2_ex: 0,
78
82
  points_ex: 0,
79
- primary_points_ex: 0,
83
+ p1_ex: 0,
80
84
  goals_en: 0,
81
85
  a1_en: 0,
82
86
  a2_en: 0,
83
87
  points_en: 0,
84
- primary_points_en: 0,
88
+ p1_en: 0,
85
89
  }
86
90
  end
87
91
 
88
92
  def add_points(goalscorer_id, a1_id, a2_id, situation)
89
93
  if goalscorer_id
90
94
  scoring_statlines[goalscorer_id]["goals_#{situation}".to_sym] += 1
91
- scoring_statlines[goalscorer_id]["primary_points_#{situation}".to_sym] += 1
95
+ scoring_statlines[goalscorer_id]["p1_#{situation}".to_sym] += 1
92
96
  end
93
97
  if a1_id
94
98
  scoring_statlines[a1_id]["a1_#{situation}".to_sym] += 1
95
- scoring_statlines[a1_id]["primary_points_#{situation}".to_sym] += 1
99
+ scoring_statlines[a1_id]["p1_#{situation}".to_sym] += 1
96
100
  end
97
101
  scoring_statlines[a2_id]["a2_#{situation}".to_sym] += 1 if a2_id
98
102
 
@@ -70,7 +70,7 @@ module AhlScraper
70
70
  }
71
71
  end
72
72
 
73
- def goal_against(goal)
73
+ def goal_against(goal) # rubocop:disable Metrics/AbcSize
74
74
  @on_ice_statline[:ga_as] += 1
75
75
  if goal[:plus_players].length >= 3 && goal[:minus_players].length >= 3 && goal[:plus_players].length <= 6 && goal[:minus_players].length <= 6
76
76
  @on_ice_statline["ga_#{goal[:minus_players].length}v#{goal[:plus_players].length}".to_sym] += 1
@@ -8,7 +8,9 @@ module AhlScraper
8
8
 
9
9
  class << self
10
10
  def list(team_id, season_id)
11
- @season_games["#{team_id}-#{season_id}"] ||= DataFetcher.new(team_id, season_id).call&.map { |team_data| TeamGameListItem.new(team_data, { team_id: team_id }) }
11
+ @season_games["#{team_id}-#{season_id}"] ||= DataFetcher.new(team_id, season_id).call&.map do |team_data|
12
+ TeamGameListItem.new(team_data, { team_id: team_id })
13
+ end
12
14
 
13
15
  @season_games["#{team_id}-#{season_id}"]
14
16
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AhlScraper
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ahl_scraper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jefftcraig
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-18 00:00:00.000000000 Z
11
+ date: 2021-10-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Allows users to gather game, season, and player data from the AHL website
14
14
  email:
@@ -50,6 +50,7 @@ files:
50
50
  - lib/ahl_scraper/fetchers/team_games/data_fetcher.rb
51
51
  - lib/ahl_scraper/fetchers/team_roster_data_fetcher.rb
52
52
  - lib/ahl_scraper/fixed_games/1001050.json
53
+ - lib/ahl_scraper/fixed_games/1003351.json
53
54
  - lib/ahl_scraper/fixed_games/1018774.json
54
55
  - lib/ahl_scraper/fixed_games/1020527.json
55
56
  - lib/ahl_scraper/games.rb
@@ -125,14 +126,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
126
  requirements:
126
127
  - - ">="
127
128
  - !ruby/object:Gem::Version
128
- version: 2.3.0
129
+ version: 2.7.0
129
130
  required_rubygems_version: !ruby/object:Gem::Requirement
130
131
  requirements:
131
132
  - - ">="
132
133
  - !ruby/object:Gem::Version
133
134
  version: '0'
134
135
  requirements: []
135
- rubygems_version: 3.2.11
136
+ rubygems_version: 3.1.6
136
137
  signing_key:
137
138
  specification_version: 4
138
139
  summary: Scrape data from the AHL website