sportdb-sync 1.0.1 → 1.0.2
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/lib/sportdb/sync/sync.rb +23 -5
- data/lib/sportdb/sync/version.rb +1 -1
- data/lib/sportdb/sync.rb +0 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 415893e89d2c9d1a8dfa9b493ecff8452095f94f
|
4
|
+
data.tar.gz: 9e55c19b40ee247d6b3b9e286b9dc799fe95c5d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e4487b6d40e296e9de680f99cb331693ccff0aac5dc3d73a55cae418f6ba9410966da1542bfa090fefa3e60123ab5822745041ab132d0876e7d89fa44ae7da7
|
7
|
+
data.tar.gz: b59e3712eb51503aee9cc7c56c604fd8c5b0513a75995b7ceefe383f67820cd25ab17f97bd32f1ca6e0dfdacab49f4333eaa5b6af82102198714f7429d0b9ea9
|
data/lib/sportdb/sync/sync.rb
CHANGED
@@ -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:
|
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:
|
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
|
-
|
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:
|
183
|
+
pos: max_pos,
|
166
184
|
play_at: match.date.to_date,
|
167
185
|
score1: match.score1,
|
168
186
|
score2: match.score2,
|
data/lib/sportdb/sync/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2020-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sportdb-config
|