sportdb-readers 2.1.0 → 2.1.1
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 +4 -4
- data/CHANGELOG.md +1 -1
- data/lib/sportdb/readers/match_reader.rb +2 -2
- data/lib/sportdb/readers/sync/match.rb +9 -40
- data/lib/sportdb/readers/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b8a59dbab5255cf06addb3d061e308969d39f8a9a90106ee59006630bee4463
|
4
|
+
data.tar.gz: 0e212bead4a0e408c639ad7e2a14a76c820a6822065c4c50bfa97f656513a3c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f23bbac50bd681fef79202831ad0094c88491abfc27c9f9ad3b7be00b090cbeb0f1045b1b9bfef4281a1e79e554e3e116e1a7d0984dbe7c9112110309fe381e
|
7
|
+
data.tar.gz: f38162e554d9760bbaeb024724a842a907d57fb48ceaba727c539e7c1e08f843cd1c82e005d858912fa1e93d602352d4cdd934227312c96acacdf86a335fc08a
|
data/CHANGELOG.md
CHANGED
@@ -213,8 +213,8 @@ class MatchReader ## todo/check: rename to MatchReaderV2 (use plural?) why? w
|
|
213
213
|
|
214
214
|
matches.each do |match|
|
215
215
|
## note: pass along stage (if present): stage - optional from heading!!!!
|
216
|
-
match = match.update( stage: stage )
|
217
|
-
match_rec = Sync::Match.
|
216
|
+
match = match.update( stage: stage ) if stage
|
217
|
+
match_rec = Sync::Match.create!( match, event: event_rec )
|
218
218
|
end
|
219
219
|
end
|
220
220
|
|
@@ -2,10 +2,7 @@ module SportDb
|
|
2
2
|
module Sync
|
3
3
|
|
4
4
|
class Match
|
5
|
-
|
6
|
-
## use update_by_round or update_by_date or update_by_teams or such
|
7
|
-
## NO easy (unique always auto-id match) possible!!!!!!
|
8
|
-
def self.create_or_update( match, event: )
|
5
|
+
def self.create!( match, event: )
|
9
6
|
## note: MUST find round, thus, use bang (!)
|
10
7
|
|
11
8
|
## todo/check: allow strings too - why? why not?
|
@@ -36,10 +33,11 @@ module Sync
|
|
36
33
|
## || Team.find_or_create( team1 ) -- note: does NOT work for string (only recs) - what to do?
|
37
34
|
## || Model::Team.find_by!( name: team1_name )
|
38
35
|
team1_name = match.team1.is_a?( String ) ? match.team1 : match.team1.name
|
39
|
-
team1_rec = Team.cache[ team1_name ]
|
40
36
|
team2_name = match.team2.is_a?( String ) ? match.team2 : match.team2.name
|
37
|
+
team1_rec = Team.cache[ team1_name ]
|
41
38
|
team2_rec = Team.cache[ team2_name ]
|
42
39
|
|
40
|
+
|
43
41
|
## check optional group (e.g. Group A, etc.)
|
44
42
|
group_rec = if match.group
|
45
43
|
group_name = match.group.is_a?( String ) ? match.group : match.group.name
|
@@ -58,30 +56,10 @@ module Sync
|
|
58
56
|
nil
|
59
57
|
end
|
60
58
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
## check for date or such - why? why not?
|
66
|
-
nil
|
67
|
-
elsif round_rec
|
68
|
-
## add match status too? allows [abandoned] and [replay] in same round
|
69
|
-
find_attributes = { round_id: round_rec.id,
|
70
|
-
team1_id: team1_rec.id,
|
71
|
-
team2_id: team2_rec.id }
|
72
|
-
|
73
|
-
## add stage if present to query
|
74
|
-
find_attributes[ :stage_id] = stage_rec.id if stage_rec
|
75
|
-
|
76
|
-
Model::Match.find_by( find_attributes )
|
77
|
-
else
|
78
|
-
## always assume new record for now
|
79
|
-
## check for date or such - why? why not?
|
80
|
-
nil
|
81
|
-
end
|
82
|
-
|
83
|
-
if rec.nil?
|
84
|
-
## find last pos - check if it can be nil? yes, is nil if no records found
|
59
|
+
|
60
|
+
rec = nil ## match record
|
61
|
+
|
62
|
+
## find last pos - check if it can be nil? yes, is nil if no records found
|
85
63
|
max_pos = Model::Match.where( event_id: event.id ).maximum( 'pos' )
|
86
64
|
max_pos = max_pos ? max_pos+1 : 1
|
87
65
|
|
@@ -90,7 +68,6 @@ module Sync
|
|
90
68
|
team2_id: team2_rec.id,
|
91
69
|
pos: max_pos,
|
92
70
|
num: match.num, ## note - might be nil (not nil for euro, world cup, etc.)
|
93
|
-
# date: match.date.to_date, ## todo/fix: split and add date & time!!!!
|
94
71
|
date: match.date, # assume iso format as string e.g. 2021-07-10 !!!
|
95
72
|
time: match.time, # assume iso format as string e.g. 21:00 !!!
|
96
73
|
score1: match.score1,
|
@@ -136,16 +113,8 @@ module Sync
|
|
136
113
|
)
|
137
114
|
end
|
138
115
|
end
|
139
|
-
|
140
|
-
|
141
|
-
puts "!! ERROR - match updates not yet supported (only inserts); sorry"
|
142
|
-
pp match
|
143
|
-
puts "---"
|
144
|
-
puts "found match record:"
|
145
|
-
pp rec
|
146
|
-
exit 1
|
147
|
-
end
|
148
|
-
rec
|
116
|
+
|
117
|
+
rec
|
149
118
|
end
|
150
119
|
end # class Match
|
151
120
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb-readers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
11
|
+
date: 2024-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sportdb-formats
|