sportdb-readers 2.1.0 → 2.2.0

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
  SHA256:
3
- metadata.gz: f272d4ffee7d8d56aa09bc05ec0280ab252ef793cc26090206e4dad41824cd43
4
- data.tar.gz: 3343b9b089991220fa61584f166a229ce1bd35aad695a0aef76ac692fc62825e
3
+ metadata.gz: 5e288d917f0333c7d12ae67eac1c8f16eeb6499cb40b9b4d6e40b45d3e617dc1
4
+ data.tar.gz: 1eb4d7e7cbf14e67141edc1043cf64cb2f3bb77fdaf1532f4f7017e95df2adaf
5
5
  SHA512:
6
- metadata.gz: 665bd28de289348d82f8bb3157e08601f20ebe35794c3e1694802fb77df34151bb15589a784c615c3c83fb3c1ad30a0e66f51a0c4a34a366dd666be3b1249d41
7
- data.tar.gz: d330593cd5ae11a2a887ef365e69c3cd02486623e9a0fbca132466eef7408b65a455ab9ee1cad6f55f6f1d706c7f901f816f23bb01060fd28457ca6df5879092
6
+ metadata.gz: 1ad5a423fb07514b374aae88cb7e858446ed75131c1aa9530b4037e521c3a8b3be9b7746cc3a13cb1010e1fa76f002f8b968858145ee593cb53f90eff28e3ef0
7
+ data.tar.gz: 19d85196f34037b618d1bbb560cc5f2b42cc4d2d006f60b7428d7bb1d72b4dc770f7c9ae2ac0f86d01eea307d36eb80bf5e4ae0511df8c5f55692c4b306e3f2c
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 2.1.0
1
+ ### 2.2.0
2
2
 
3
3
  ### 0.0.1 / 2019-10-29
4
4
 
@@ -9,16 +9,6 @@ module SportDb
9
9
  class MatchReader ## todo/check: rename to MatchReaderV2 (use plural?) why? why not?
10
10
 
11
11
 
12
- ### fix - remove catalog reference!!!
13
- ## use classes with "augmented" static methods
14
- ## e.g. Club.match_by etc.
15
- def catalog
16
- puts "[deprecated] do NOT use catalog reference; use classes with enhanced search static methods!"
17
- Import.catalog
18
- end
19
-
20
-
21
-
22
12
  def self.read( path, season: nil ) ## use - rename to read_file or from_file etc. - why? why not?
23
13
  txt = File.open( path, 'r:utf-8' ) {|f| f.read }
24
14
  parse( txt, season: season )
@@ -73,8 +63,8 @@ class MatchReader ## todo/check: rename to MatchReaderV2 (use plural?) why? w
73
63
 
74
64
  ### check if event info available - use start_date;
75
65
  ## otherwise we have to guess (use a "synthetic" start_date)
76
- event_info = catalog.events.find_by( season: season,
77
- league: league )
66
+ event_info = Import::EventInfo.find_by( season: season,
67
+ league: league )
78
68
 
79
69
  start = if event_info && event_info.start_date
80
70
  puts "event info found:"
@@ -116,8 +106,8 @@ class MatchReader ## todo/check: rename to MatchReaderV2 (use plural?) why? w
116
106
  puts "league:"
117
107
  pp league
118
108
 
119
- teams = catalog.teams.find_by!( name: auto_conf_teams,
120
- league: league )
109
+ teams = Import::Team.find_by!( name: auto_conf_teams,
110
+ league: league )
121
111
 
122
112
  puts " [debug] teams:"
123
113
  pp teams
@@ -213,8 +203,8 @@ class MatchReader ## todo/check: rename to MatchReaderV2 (use plural?) why? w
213
203
 
214
204
  matches.each do |match|
215
205
  ## note: pass along stage (if present): stage - optional from heading!!!!
216
- match = match.update( stage: stage ) if stage
217
- match_rec = Sync::Match.create_or_update( match, event: event_rec )
206
+ match = match.update( stage: stage ) if stage
207
+ match_rec = Sync::Match.create!( match, event: event_rec )
218
208
  end
219
209
  end
220
210
 
@@ -2,10 +2,7 @@ module SportDb
2
2
  module Sync
3
3
 
4
4
  class Match
5
- ### todo/fix: rename to create!! (add update support later) !!!!
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
- ### todo/check: what happens if there's more than one match? exception raised??
62
- rec = if ['N. N.', 'N.N.'].include?( team1_name ) && ## some special cases - always assume new record for now (to avoid ambigious update conflict)
63
- ['N. N.', 'N.N.'].include?( team2_name )
64
- ## always assume new record for now
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
- else
140
- # update - todo
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
 
@@ -4,7 +4,7 @@ module SportDb
4
4
  module Module
5
5
  module Readers
6
6
  MAJOR = 2 ## todo: namespace inside version or something - why? why not??
7
- MINOR = 1
7
+ MINOR = 2
8
8
  PATCH = 0
9
9
  VERSION = [MAJOR,MINOR,PATCH].join('.')
10
10
 
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.0
4
+ version: 2.2.0
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-26 00:00:00.000000000 Z
11
+ date: 2024-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sportdb-formats