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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 397b58e2e8ed6c6c747f9ac04885cf7040152e83
4
- data.tar.gz: 99f0d69e4f45a7c000325268e4d63bec53af8941
3
+ metadata.gz: e69405f0f6aab33c299ed7479747f1adb6e90282
4
+ data.tar.gz: ef45575530d5b0e899ff08f69089462486fd580a
5
5
  SHA512:
6
- metadata.gz: cb1cb72c8ee98549af0ed85879ba8e5490afae58747a2ddd25356f3886e5d72672a0f1badda739baed05646e5b2ceceefe2f0b7a4bfb932ff6425a4a7dedccc6
7
- data.tar.gz: 93cee1c25615d5fcce27b414f2bd964f411ddf3f110ca15863631c44ae38b14b11585e206dbd966a68f68391a1ae116cb5b584105f341a4f2ba38aa9565587df
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-config', '>= 1.1.0'],
24
- ['sportdb-models', '>= 2.0.1'],
23
+ ['sportdb-catalogs', '>= 1.0.0'],
24
+ ['sportdb-models', '>= 2.0.2'],
25
25
  ]
26
26
 
27
27
  self.spec_extras = {
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'sportdb/config'
3
+ require 'sportdb/catalogs'
4
4
  require 'sportdb/models' ## add sql database support
5
5
 
6
6
 
@@ -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
- ## query for round - allow string or round rec
146
- round_name = match.round.is_a?( String ) ? match.round : match.round.name
147
- round_rec = Model::Round.find_by!( event_id: event.id,
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 once match? exception raised??
178
- rec = Model::Match.find_by( round_id: round_rec.id,
179
- team1_id: team1_rec.id,
180
- team2_id: team2_rec.id )
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
@@ -7,7 +7,7 @@ module Sync
7
7
 
8
8
  MAJOR = 1 ## todo: namespace inside version or something - why? why not??
9
9
  MINOR = 1
10
- PATCH = 0
10
+ PATCH = 1
11
11
  VERSION = [MAJOR,MINOR,PATCH].join('.')
12
12
 
13
13
  def self.version
@@ -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-config/lib' ))
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.0
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-06-15 00:00:00.000000000 Z
11
+ date: 2020-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: sportdb-config
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.1.0
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.1.0
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.1
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.1
40
+ version: 2.0.2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rdoc
43
43
  requirement: !ruby/object:Gem::Requirement