sportdb-sync 1.0.1 → 1.0.2

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: 348a66cb30ccc072d2f6e0a82f61af6234e193d2
4
- data.tar.gz: cae64f1ab5a09c9b0cd930d49a62f4b3a565eceb
3
+ metadata.gz: 415893e89d2c9d1a8dfa9b493ecff8452095f94f
4
+ data.tar.gz: 9e55c19b40ee247d6b3b9e286b9dc799fe95c5d7
5
5
  SHA512:
6
- metadata.gz: a864409290725d1ed3d6cf529ae7bf30c6091f28e76ce01fe427b1ff0cf31349d049a07e7de39c599f8e8db1b0136c2e2d7e1750aac1eab90b43e78a4153d4b4
7
- data.tar.gz: b28d7dd3b5202cb3d58e1afb7e24c21f45e6b74c19391717257e16332c93470f17a78810314252bd4ce24758bc50af1d6d533ccbc41d712bb6d1282943533797
6
+ metadata.gz: 4e4487b6d40e296e9de680f99cb331693ccff0aac5dc3d73a55cae418f6ba9410966da1542bfa090fefa3e60123ab5822745041ab132d0876e7d89fa44ae7da7
7
+ data.tar.gz: b59e3712eb51503aee9cc7c56c604fd8c5b0513a75995b7ceefe383f67820cd25ab17f97bd32f1ca6e0dfdacab49f4333eaa5b6af82102198714f7429d0b9ea9
@@ -66,11 +66,18 @@ module SportDb
66
66
  def self.find_or_create( round, event: )
67
67
  rec = Model::Round.find_by( title: round.title, event_id: event.id )
68
68
  if rec.nil?
69
+ ## find last pos - check if it can be nil?
70
+ max_pos = Model::Round.where( event_id: event.id ).maximum( 'pos' )
71
+ max_pos = max_pos ? max_pos+1 : 1
72
+
69
73
  attribs = { event_id: event.id,
70
74
  title: round.title,
71
- pos: round.pos,
72
- start_at: event.start_at.to_date
75
+ pos: max_pos
73
76
  }
77
+
78
+ ## todo/fix: check if round has (optional) start or end date and add!!!
79
+ ## attribs[ :start_at] = round.start_at.to_date
80
+
74
81
  rec = Model::Round.create!( attribs )
75
82
  end
76
83
  rec
@@ -82,10 +89,16 @@ module SportDb
82
89
  def self.find_or_create( group, event: )
83
90
  rec = Model::Group.find_by( title: group.title, event_id: event.id )
84
91
  if rec.nil?
92
+ ## find last pos - check if it can be nil?
93
+ max_pos = Model::Group.where( event_id: event.id ).maximum( 'pos' )
94
+ max_pos = max_pos ? max_pos+1 : 1
95
+
85
96
  attribs = { event_id: event.id,
86
97
  title: group.title,
87
- pos: group.pos
98
+ pos: max_pos
88
99
  }
100
+
101
+ ## todo/fix: check/add optional group key (was: pos before)!!!!
89
102
  rec = Model::Group.create!( attribs )
90
103
  end
91
104
  ## todo/fix: add/update teams in group too!!!!!
@@ -159,10 +172,15 @@ module SportDb
159
172
  team1_id: team1_rec.id,
160
173
  team2_id: team2_rec.id )
161
174
  if rec.nil?
162
- attribs = { round_id: round_rec.id,
175
+ ## find last pos - check if it can be nil?
176
+ max_pos = Model::Game.where( event_id: event.id ).maximum( 'pos' )
177
+ max_pos = max_pos ? max_pos+1 : 1
178
+
179
+ attribs = { event_id: event.id, ## todo/fix: change to data struct too?
180
+ round_id: round_rec.id,
163
181
  team1_id: team1_rec.id,
164
182
  team2_id: team2_rec.id,
165
- pos: 999, ## make optional why? why not? - change to num?
183
+ pos: max_pos,
166
184
  play_at: match.date.to_date,
167
185
  score1: match.score1,
168
186
  score2: match.score2,
@@ -7,7 +7,7 @@ module Sync
7
7
 
8
8
  MAJOR = 1 ## todo: namespace inside version or something - why? why not??
9
9
  MINOR = 0
10
- PATCH = 1
10
+ PATCH = 2
11
11
  VERSION = [MAJOR,MINOR,PATCH].join('.')
12
12
 
13
13
  def self.version
data/lib/sportdb/sync.rb CHANGED
@@ -4,17 +4,6 @@ require 'sportdb/config'
4
4
  require 'sportdb/models' ## add sql database support
5
5
 
6
6
 
7
- ##
8
- # fix!!!
9
- # patches for worlddb/models - move upstream!!!!
10
- module WorldDb
11
- COUNTRY_KEY_PATTERN = '\A[a-z]{2,}\z' # allow two AND three letter keys e.g. at, mx, eng, sco, etc.
12
- COUNTRY_KEY_PATTERN_MESSAGE = "expected two or more lowercase letters a-z /#{COUNTRY_KEY_PATTERN}/"
13
-
14
- COUNTRY_CODE_PATTERN = '\A[A-Z_]{2,}\z'
15
- COUNTRY_CODE_PATTERN_MESSAGE = "expected two or more uppercase letters A-Z (and _) /#{COUNTRY_CODE_PATTERN}/"
16
- end # module WorldDb
17
-
18
7
 
19
8
  ###
20
9
  # our own code
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb-sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
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-05-19 00:00:00.000000000 Z
11
+ date: 2020-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sportdb-config