sportradar-api 0.9.49 → 0.9.50

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: 7a724c9e4a9459457f501ab3655f104eb38650b8
4
- data.tar.gz: ee588df375323ca59c79e1a1d86d0671d1ad3931
3
+ metadata.gz: a8b3f838e353649a09d7cb7426d836f688be649e
4
+ data.tar.gz: 6c1ad1d9434664ff88e74dafd7b00927d1561a53
5
5
  SHA512:
6
- metadata.gz: 2b7ee936ac83c8c072e75cd44cc3e76980cda0bfff21a2345125e78998fb219656dd354213ab2436ae146cba89833ad8dd8db0a745f6f6ddb365d03fa120d8df
7
- data.tar.gz: 3baa18ac182d16449bbd009065f9f834e4c0b0d5d2b5a9847e43ddda6cd0962d40d307e212dde838a85d86f6bf5c1265f1af918b65dcd8b5d12cfbf742502727
6
+ metadata.gz: 2e0987f422d575c4190a4770e67f4dc22a2a71c573569450bbb98ec97b27e322bb76af6a8fcd96f1c244dc986a44519cc07f7744aa0496338fe66148e673c8ec
7
+ data.tar.gz: 1d6c967e3c6eaf1e967b3e51f81b2c4948de6127a5056d2fbc253121ac82d32ed4b1a9a14707bdc6d1e9db9421786ad76bb21ea7ffc74ecb0391e3fb2b7825c6
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sportradar-api (0.9.49)
4
+ sportradar-api (0.9.50)
5
5
  activesupport
6
6
  httparty (>= 0.14.0)
7
7
 
@@ -41,7 +41,8 @@ module Sportradar
41
41
  # handle data from team (all quarters)
42
42
  # handle data from quarter (both teams)
43
43
  # handle data from game?
44
- @scores.each { |k, v| v.merge!(new_scores.fetch(k, {})) }
44
+ @scores.each { |k, v| v.merge!(new_scores.delete(k) || {} ) }
45
+ new_scores.each { |k, v| @scores.merge!(k => v) }
45
46
  end
46
47
 
47
48
  def points(team_id)
@@ -54,19 +55,27 @@ module Sportradar
54
55
  def parse_from_box(data)
55
56
  id = data.dig('team', 0, 'id')
56
57
  da = data.dig('team', 0, 'scoring', 'quarter')
57
- a = [da].compact.flatten(1).each { |h| h[id] = h.delete('points').to_i }
58
+ da_ot = data.dig('team', 0, 'scoring', 'overtime')
59
+ arr = [da].compact.flatten(1)
60
+ a = arr + [da_ot].compact.flatten(1)
61
+ a.each { |h| h[id] = h.delete('points').to_i }
58
62
  id = data.dig('team', 1, 'id')
59
63
  da = data.dig('team', 1, 'scoring', 'quarter')
60
- b = [da].compact.flatten(1).each { |h| h[id] = h.delete('points').to_i }
61
- a.zip(b).map{ |a, b| [a['number'].to_i, a.merge(b)] }.sort{ |(a,_), (b,_)| a <=> b }.to_h
64
+ da_ot = data.dig('team', 1, 'scoring', 'overtime')
65
+ arr = [da].compact.flatten(1)
66
+ b = arr + [da_ot].compact.flatten(1)
67
+ b.each { |h| h[id] = h.delete('points').to_i }
68
+ a.zip(b).map{ |a, b| [a['sequence'].to_i, a.merge(b)] }.sort{ |(a,_), (b,_)| a <=> b }.to_h
62
69
  rescue => e
63
70
  binding.pry
64
71
  end
65
72
 
66
73
  def parse_from_pbp(data)
67
74
  quarters = data['quarter'][1..-1]
75
+ overtimes = data['overtime']
76
+ overtimes = [overtimes] if overtimes.is_a?(Hash)
68
77
  quarters = quarters[0] if quarters.is_a?(Array)
69
- data = quarters.map{|q| q['scoring'] }
78
+ data = (quarters + overtimes).map{|q| q['scoring'] }
70
79
  data.map.with_index(1) { |h, i| [i, { h.dig('home', 'id') => h.dig('home', 'points').to_i, h.dig('away', 'id') => h.dig('away', 'points').to_i }] }.to_h
71
80
  rescue => e
72
81
  {}
@@ -1,5 +1,5 @@
1
1
  module Sportradar
2
2
  module Api
3
- VERSION = "0.9.49"
3
+ VERSION = "0.9.50"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportradar-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.49
4
+ version: 0.9.50
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Eggett