sportradar-api 0.11.68 → 0.11.69
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0c7084f28ea2be5219232796dc40f7f691d24cd2
|
|
4
|
+
data.tar.gz: ceca9d5cd1f2133f03d4664faf6cc7db764a98fd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e4068cd6ccb040bc0df56015dacb0bc29f8be8f399bc664d345ee3a01095757b782dae5d9356580f4d3f1dc83e0d6406eed327e10eb24650d582cadbdf6e2516
|
|
7
|
+
data.tar.gz: 4fa08f20dc69fb0d988f7c8029b95d7d72b5f3e87e3ea1bef97cefe126628966ac54f20181223b827a8253942250c2cf6a23690daaef9ec49bb7fc056046ace9
|
data/Gemfile.lock
CHANGED
|
@@ -19,12 +19,12 @@ module Sportradar
|
|
|
19
19
|
@preferred_name = data["preferred_name"]
|
|
20
20
|
@jersey_number = data["jersey_number"]
|
|
21
21
|
|
|
22
|
-
update(data)
|
|
22
|
+
# update(data)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def update(data, **opts)
|
|
26
|
-
lineup = event.half_inning.inning.game.lineup
|
|
27
|
-
lineup.update_from_lineup_event(data)
|
|
26
|
+
# lineup = event.half_inning.inning.game.lineup
|
|
27
|
+
# lineup.update_from_lineup_event(data)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def data_key
|
|
@@ -131,7 +131,7 @@ module Sportradar
|
|
|
131
131
|
update_bases(data)
|
|
132
132
|
parse_pitchers(data) if data['home'] && data['away']
|
|
133
133
|
|
|
134
|
-
lineup.update(data, source: source)
|
|
134
|
+
lineup.update(data, source: source) unless source == :pbp
|
|
135
135
|
if data['scoring']
|
|
136
136
|
parse_score(data['scoring'])
|
|
137
137
|
elsif data.dig('home', 'hits')
|
|
@@ -429,6 +429,8 @@ module Sportradar
|
|
|
429
429
|
innings = data['innings'].each { |inning| inning['id'] = "#{data['id']}-#{inning['number']}" }
|
|
430
430
|
create_data(@innings_hash, innings, klass: Inning, api: api, game: self) if data['innings']
|
|
431
431
|
extract_count(data)
|
|
432
|
+
lineup.update(data, source: :pbp)
|
|
433
|
+
# update lineups
|
|
432
434
|
check_newness(:pitches, pitches.last&.id)
|
|
433
435
|
check_newness(:events, events.last&.description)
|
|
434
436
|
check_newness(:score, @score)
|
|
@@ -10,6 +10,14 @@ module Sportradar
|
|
|
10
10
|
def update(data, source: nil)
|
|
11
11
|
case source
|
|
12
12
|
when :pbp
|
|
13
|
+
@home = initial_lineup.dup
|
|
14
|
+
@away = initial_lineup.dup
|
|
15
|
+
lineups = game.events.select {|ev| ev.lineup }.map(&:lineup)
|
|
16
|
+
lineups.each do |line|
|
|
17
|
+
player_data = line.response
|
|
18
|
+
player_data['id'] = player_data.delete('player_id')
|
|
19
|
+
update_from_lineup_event(player_data)
|
|
20
|
+
end
|
|
13
21
|
when :summary
|
|
14
22
|
@roster = (data.dig('home', 'roster') || []) + (data.dig('away', 'roster') || [])
|
|
15
23
|
return unless data.dig('home', 'lineup') && data.dig('away', 'lineup')
|
|
@@ -21,10 +29,10 @@ module Sportradar
|
|
|
21
29
|
end
|
|
22
30
|
|
|
23
31
|
def update_from_lineup_event(data)
|
|
24
|
-
if data.dig('
|
|
25
|
-
update_home(
|
|
26
|
-
elsif data.dig('
|
|
27
|
-
update_away(
|
|
32
|
+
if data.dig('team_id') == game.home_id
|
|
33
|
+
update_home(data, data.dig('order'))
|
|
34
|
+
elsif data.dig('team_id') == game.away_id
|
|
35
|
+
update_away(data, data.dig('order'))
|
|
28
36
|
end
|
|
29
37
|
end
|
|
30
38
|
|
|
@@ -69,27 +77,27 @@ module Sportradar
|
|
|
69
77
|
def next_batters(team, number_of_upcoming_batters = 3)
|
|
70
78
|
if team == 'home'
|
|
71
79
|
last_at_bat = game.at_bats.select{|at_bat| at_bat.event.half_inning.half == 'B'}.last
|
|
72
|
-
if last_at_bat
|
|
73
|
-
last_position = @
|
|
80
|
+
if last_at_bat
|
|
81
|
+
last_position = @home.detect{|htl| htl['id'] == last_at_bat.hitter_id}&.dig('order')
|
|
74
82
|
upcoming = home.rotate(last_position || 0)
|
|
75
|
-
else
|
|
83
|
+
else # first inning
|
|
76
84
|
upcoming = home
|
|
77
85
|
end
|
|
78
86
|
elsif team == 'away'
|
|
79
87
|
last_at_bat = game.at_bats.select{|at_bat| at_bat.event.half_inning.half == 'T'}.last
|
|
80
|
-
if last_at_bat
|
|
81
|
-
last_position = @
|
|
88
|
+
if last_at_bat
|
|
89
|
+
last_position = @away.detect{|atl| atl['id'] == last_at_bat.hitter_id}&.dig('order')
|
|
82
90
|
upcoming = away.rotate(last_position || 0)
|
|
83
|
-
else
|
|
91
|
+
else # first inning
|
|
84
92
|
upcoming = away
|
|
85
93
|
end
|
|
86
94
|
end
|
|
87
95
|
upcoming[0..(number_of_upcoming_batters - 1)]
|
|
88
|
-
rescue => e
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
96
|
+
# rescue => e
|
|
97
|
+
# i ||= 0
|
|
98
|
+
# game.get_summary
|
|
99
|
+
# i += 1
|
|
100
|
+
# retry unless i > 2
|
|
93
101
|
end
|
|
94
102
|
|
|
95
103
|
private
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sportradar-api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.11.
|
|
4
|
+
version: 0.11.69
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ben Eggett
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-09-
|
|
11
|
+
date: 2017-09-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|