sportdb-sync 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -2
- data/lib/sportdb/sync.rb +1 -1
- data/lib/sportdb/sync/sync.rb +32 -10
- data/lib/sportdb/sync/version.rb +1 -1
- data/test/helper.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e69405f0f6aab33c299ed7479747f1adb6e90282
|
4
|
+
data.tar.gz: ef45575530d5b0e899ff08f69089462486fd580a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f969dc99e13d4b5b98fddf63925e44f24e799cc5ae7d6ee8db34738e1140c9bbe8657199f389586a9ef6a16b895e39207f3e34e98b264c978934a853ee08800e
|
7
|
+
data.tar.gz: 51a8e71e961fdd780561a038afe381026c5aca39838f210825b72f2aafc583bc85db62e5cf6190e32ec1256a983d410de26e1033b5ed9257020819e6894f4bd2
|
data/Rakefile
CHANGED
@@ -20,8 +20,8 @@ Hoe.spec 'sportdb-sync' do
|
|
20
20
|
self.licenses = ['Public Domain']
|
21
21
|
|
22
22
|
self.extra_deps = [
|
23
|
-
['sportdb-
|
24
|
-
['sportdb-models',
|
23
|
+
['sportdb-catalogs', '>= 1.0.0'],
|
24
|
+
['sportdb-models', '>= 2.0.2'],
|
25
25
|
]
|
26
26
|
|
27
27
|
self.spec_extras = {
|
data/lib/sportdb/sync.rb
CHANGED
data/lib/sportdb/sync/sync.rb
CHANGED
@@ -137,15 +137,22 @@ module SportDb
|
|
137
137
|
|
138
138
|
|
139
139
|
class Match
|
140
|
+
### todo/fix: rename to create!! (add update support later) !!!!
|
141
|
+
## use update_by_round or update_by_date or update_by_teams or such
|
142
|
+
## NO easy (unique always auto-id match) possible!!!!!!
|
140
143
|
def self.create_or_update( match, event: )
|
141
144
|
## note: MUST find round, thus, use bang (!)
|
142
145
|
|
143
146
|
## todo/check: allow strings too - why? why not?
|
144
147
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
+
round_rec = if match.round
|
149
|
+
## query for round - allow string or round rec
|
150
|
+
round_name = match.round.is_a?( String ) ? match.round : match.round.name
|
151
|
+
Model::Round.find_by!( event_id: event.id,
|
148
152
|
name: round_name )
|
153
|
+
else # note: allow matches WITHOUT rounds too (e.g. England Football League 1888 and others)
|
154
|
+
nil
|
155
|
+
end
|
149
156
|
|
150
157
|
## todo/check: allow fallback with db lookup if NOT found in cache - why? why not?
|
151
158
|
## or better use Sync::Team.find_or_create( team ) !!!!!!! to auto-create on first hit!
|
@@ -174,17 +181,24 @@ module SportDb
|
|
174
181
|
nil
|
175
182
|
end
|
176
183
|
|
177
|
-
### todo/check: what happens if there's more than
|
178
|
-
rec =
|
179
|
-
|
180
|
-
|
184
|
+
### todo/check: what happens if there's more than one match? exception raised??
|
185
|
+
rec = if round_rec
|
186
|
+
## add match status too? allows [abandoned] and [replay] in same round
|
187
|
+
Model::Match.find_by( round_id: round_rec.id,
|
188
|
+
team1_id: team1_rec.id,
|
189
|
+
team2_id: team2_rec.id )
|
190
|
+
else
|
191
|
+
## always assume new record for now
|
192
|
+
## check for date or such - why? why not?
|
193
|
+
nil
|
194
|
+
end
|
195
|
+
|
181
196
|
if rec.nil?
|
182
197
|
## find last pos - check if it can be nil? yes, is nil if no records found
|
183
198
|
max_pos = Model::Match.where( event_id: event.id ).maximum( 'pos' )
|
184
199
|
max_pos = max_pos ? max_pos+1 : 1
|
185
200
|
|
186
201
|
attribs = { event_id: event.id, ## todo/fix: change to data struct too?
|
187
|
-
round_id: round_rec.id,
|
188
202
|
team1_id: team1_rec.id,
|
189
203
|
team2_id: team2_rec.id,
|
190
204
|
pos: max_pos,
|
@@ -192,14 +206,22 @@ module SportDb
|
|
192
206
|
score1: match.score1,
|
193
207
|
score2: match.score2,
|
194
208
|
score1i: match.score1i,
|
195
|
-
score2i: match.score2i
|
196
|
-
|
209
|
+
score2i: match.score2i,
|
210
|
+
score1et: match.score1et,
|
211
|
+
score2et: match.score2et,
|
212
|
+
score1p: match.score1p,
|
213
|
+
score2p: match.score2p,
|
214
|
+
status: match.status }
|
215
|
+
|
216
|
+
attribs[ :round_id ] = round_rec.id if round_rec
|
197
217
|
attribs[ :group_id ] = group_rec.id if group_rec
|
198
218
|
attribs[ :stage_id ] = stage_rec.id if stage_rec
|
199
219
|
|
200
220
|
rec = Model::Match.create!( attribs )
|
201
221
|
else
|
202
222
|
# update - todo
|
223
|
+
puts "!! ERROR - match updates not yet supported (only inserts); sorry"
|
224
|
+
exit 1
|
203
225
|
end
|
204
226
|
rec
|
205
227
|
end
|
data/lib/sportdb/sync/version.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
## note: use the local version of sportdb gems
|
2
2
|
$LOAD_PATH.unshift( File.expand_path( '../sportdb-formats/lib' ))
|
3
|
-
$LOAD_PATH.unshift( File.expand_path( '../sportdb-
|
3
|
+
$LOAD_PATH.unshift( File.expand_path( '../sportdb-catalogs/lib' ))
|
4
4
|
$LOAD_PATH.unshift( File.expand_path( '../sportdb-models/lib' ))
|
5
5
|
|
6
6
|
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb-sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.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: 2020-
|
11
|
+
date: 2020-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: sportdb-
|
14
|
+
name: sportdb-catalogs
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sportdb-models
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.0.
|
33
|
+
version: 2.0.2
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.0.
|
40
|
+
version: 2.0.2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rdoc
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|