sportdb-readers 1.2.0 → 1.2.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
  SHA256:
3
- metadata.gz: 40a0db453b48c9bed47b6370c44249d5c8197df2fddc90a911653f2ddd145357
4
- data.tar.gz: 8792558c03345ba1662249e5239f5b6122324740f353be4143c420f482486742
3
+ metadata.gz: 1298cb753fdadf33ad2bc2a8c756b16fc9abc06d12ba54705a9d8dc970f0fb5d
4
+ data.tar.gz: 4b367725fe4e6c18d77bc822152d9da086aa713519f2d676a26ef23ee2e48714
5
5
  SHA512:
6
- metadata.gz: 342de18d45ec3be01a528be68e2e77d18866911cef7fbad17424179c648eda816170e77ea39987bfa66b48af9627284080535eab292c0e9798e3ca25ad09118a
7
- data.tar.gz: 5861f675107c90fdd10f865396df5b43f30df1df63ff3e437f409612853b393d575f96df0b59a86d23c2773791a2a63d57db1df9949ebb4e0845768b088a9654
6
+ metadata.gz: 202056abc1d45c64ae2ce8855841b71a130e80db244d5d2b2e279b77c4f839588dee9094cdb2780d20678c36bf3e1eb3b340946f23f7e7ab48db8966238d1f5f
7
+ data.tar.gz: '062494236d53dd2fa51209a520cfd0c3507a3750a802864f462b749d1188d0c13c68fa3679f1fe6839daed570589399ef34407566bb95a7d7fce038abd15d290'
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 1.2.0
1
+ ### 1.2.1
2
2
 
3
3
  ### 0.0.1 / 2019-10-29
4
4
 
data/README.md CHANGED
@@ -50,15 +50,14 @@ Matchday 1
50
50
  ...
51
51
  ```
52
52
 
53
- (Source: [england/2015-16/1-premierleague-i.txt](https://github.com/openfootball/england/blob/master/2015-16/1-premierleague-i.txt))
53
+ (Source: [england/2015-16/1-premierleague.txt](https://github.com/openfootball/england/blob/master/2015-16/1-premierleague.txt))
54
54
 
55
55
  and let's try:
56
56
 
57
57
  ``` ruby
58
58
  ## assumes football.db datasets for England in ./england directory
59
59
  ## see github.com/openfootball/england
60
- SportDb.read( './england/2015-16/1-premierleague-i.txt' )
61
- SportDb.read( './england/2015-16/1-premierleague-ii.txt' )
60
+ SportDb.read( './england/2015-16/1-premierleague.txt' )
62
61
 
63
62
  ## let's try another season
64
63
  SportDb.read( './england/2019-20/1-premierleague.txt' )
@@ -136,7 +135,7 @@ Round, Date, Team 1, FT, HT, Team 2
136
135
  ```
137
136
  (Source: [england/2019-20/eng.1.csv](https://github.com/footballcsv/england/blob/master/2010s/2019-20/eng.1.csv))
138
137
 
139
- Yes, you can. See the [sportdb-importers library / gem »](https://github.com/sportdb/sport.db/tree/master/sportdb-importers)
138
+ Yes, you can. See the [sportdb-importers library / gem »](https://github.com/sportdb/sport.db/tree/master/sportdb-importers)
140
139
 
141
140
 
142
141
 
data/Rakefile CHANGED
@@ -20,11 +20,11 @@ Hoe.spec 'sportdb-readers' do
20
20
  self.licenses = ['Public Domain']
21
21
 
22
22
  self.extra_deps = [
23
- ['sportdb-sync', '>= 1.2.0'],
23
+ ['sportdb-sync', '>= 1.2.2'],
24
24
  ]
25
25
 
26
26
  self.spec_extras = {
27
- required_ruby_version: '>= 2.2.2'
27
+ required_ruby_version: '>= 3.1.0'
28
28
  }
29
29
 
30
30
  end
@@ -23,43 +23,22 @@ class MatchReader ## todo/check: rename to MatchReaderV2 (use plural?) why? w
23
23
  secs = LeagueOutlineReader.parse( @txt, season: season )
24
24
  pp secs
25
25
 
26
-
27
- ###
28
- ## todo/check/fix: move to LeagueOutlineReader for (re)use - why? why not?
29
- ## use sec[:lang] or something?
30
- langs = { ## map country keys to lang codes
31
- 'de' => 'de', ## de - Deutsch (German)
32
- 'at' => 'de',
33
- 'ch' => 'de',
34
- 'fr' => 'fr', ## fr - French
35
- 'it' => 'it', ## it - Italian
36
- 'es' => 'es', ## es - Español (Spanish)
37
- 'mx' => 'es',
38
- 'ar' => 'es', ## Argentina
39
- 'pt' => 'pt', ## pt - Português (Portuguese)
40
- 'br' => 'pt',
41
- }
42
-
43
26
  secs.each do |sec| ## sec(tion)s
44
27
  season = sec[:season]
45
28
  league = sec[:league]
46
29
  stage = sec[:stage]
47
30
  lines = sec[:lines]
48
31
 
49
- ## hack for now: switch lang
50
- ## todo/fix: set lang for now depending on league country!!!
51
- if league.intl? ## todo/fix: add intl? to ActiveRecord league!!!
52
- Import.config.lang = 'en'
53
- else ## assume national/domestic
54
- Import.config.lang = langs[ league.country.key ] || 'en'
55
- end
56
-
57
32
  ### check if event info availabe - use start_date;
58
33
  ## otherwise we have to guess (use a "synthetic" start_date)
59
34
  event_info = catalog.events.find_by( season: season,
60
35
  league: league )
61
36
 
62
37
  start = if event_info && event_info.start_date
38
+ puts "event info found:"
39
+ puts " using start date from event: "
40
+ pp event_info
41
+ pp event_info.start_date
63
42
  event_info.start_date
64
43
  else
65
44
  if season.year?
@@ -70,61 +49,101 @@ class MatchReader ## todo/check: rename to MatchReaderV2 (use plural?) why? w
70
49
  end
71
50
 
72
51
 
73
- ### todo/check: make sure team include teams from group def too!!!!!
74
- ###
75
- ### note - only use teams and grounds for now
76
- auto_conf_teams,
77
- _rounds, _groups, _round_defs, _group_defs,
78
- auto_conf_grounds,
79
- _ = AutoConfParser.parse( lines, start: start )
80
-
81
-
52
+ parser = MatchParser.new( lines,
53
+ start ) ## note: keep season start_at date for now (no need for more specific stage date need for now)
54
+
55
+ auto_conf_teams, matches, rounds, groups = parser.parse
56
+
57
+ puts ">>> #{auto_conf_teams.size} teams:"
58
+ pp auto_conf_teams
59
+ puts ">>> #{matches.size} matches:"
60
+ ## pp matches
61
+ puts ">>> #{rounds.size} rounds:"
62
+ pp rounds
63
+ puts ">>> #{groups.size} groups:"
64
+ pp groups
65
+
66
+
67
+
82
68
  ## step 1: map/find teams
83
69
 
84
70
  ## note: loop over keys (holding the names); values hold the usage counter!! e.g. 'Arsenal' => 2, etc.
85
71
  mods = nil
86
72
  if league.clubs? && league.intl? ## todo/fix: add intl? to ActiveRecord league!!!
73
+
74
+ ## quick hack - use "dynamic" keys for keys
75
+ uefa_el_q = catalog.leagues.match_by( code: 'uefa.el.quali' )[0]
76
+ uefa_cl_q = catalog.leagues.match_by( code: 'uefa.cl.quali' )[0]
77
+ uefa_cl = catalog.leagues.match_by( code: 'uefa.cl' )[0]
78
+ uefa_el = catalog.leagues.match_by( code: 'uefa.el' )[0]
79
+
80
+ pp [uefa_el_q, uefa_cl_q, uefa_cl, uefa_el]
81
+
87
82
  ### quick hack mods for popular/known ambigious club names
88
83
  ## todo/fix: make more generic / reuseable!!!!
89
84
  mods = {}
90
85
  ## europa league uses same mods as champions league
91
- mods[ 'uefa.el.quali' ] =
92
- mods[ 'uefa.cl.quali' ] =
93
- mods[ 'uefa.el' ] =
94
- mods[ 'uefa.cl' ] = catalog.clubs.build_mods(
86
+ mods[ uefa_el_q.key ] =
87
+ mods[ uefa_cl_q.key ] =
88
+ mods[ uefa_el.key ] =
89
+ mods[ uefa_cl.key ] = catalog.clubs.build_mods(
95
90
  { 'Liverpool | Liverpool FC' => 'Liverpool FC, ENG',
96
91
  'Arsenal | Arsenal FC' => 'Arsenal FC, ENG',
97
92
  'Barcelona' => 'FC Barcelona, ESP',
98
- 'Valencia' => 'Valencia CF, ESP' })
93
+ 'Valencia' => 'Valencia CF, ESP',
94
+ 'Rangers FC' => 'Rangers FC, SCO',
95
+ })
99
96
  end
100
97
 
101
98
  # puts " [debug] auto_conf_teams:"
102
99
  # pp auto_conf_teams
103
100
 
104
101
 
105
- teams = catalog.teams.find_by!( name: auto_conf_teams.keys,
102
+ ## todo/fix
103
+ ## ** !!! ERROR - too many matches (2) for club >Barcelona<:
104
+ ## [<Club: FC Barcelona (ESP)>, <Club: Barcelona Guayaquil (ECU)>]
105
+
106
+ puts "league:"
107
+ pp league
108
+
109
+ teams = catalog.teams.find_by!( name: auto_conf_teams,
106
110
  league: league,
107
111
  mods: mods )
108
112
 
109
- # puts " [debug] teams:"
110
- # pp teams
113
+ puts " [debug] teams:"
114
+ pp teams
115
+
111
116
 
112
117
  ## build mapping - name => team struct record
113
- team_mapping = auto_conf_teams.keys.zip( teams ).to_h
118
+ team_mapping = auto_conf_teams.zip( teams ).to_h
114
119
 
115
- # puts " [debug] team_mapping:"
116
- # pp team_mapping
120
+ puts " [debug] team_mapping:"
121
+ pp team_mapping
117
122
 
118
-
119
123
 
120
- parser = MatchParser.new( lines,
121
- team_mapping,
122
- start ) ## note: keep season start_at date for now (no need for more specific stage date need for now)
124
+ ## quick (and dirty) hack
125
+ ## update all team strings with mapped records
126
+ matches.each do |match|
127
+ match.update( team1: team_mapping[ match.team1 ] )
128
+ match.update( team2: team_mapping[ match.team2 ] )
129
+ end
123
130
 
124
- matches, rounds, groups = parser.parse
131
+ ## quick hack cont.
132
+ ## rebuild groups with all team strings with mapped records
133
+ groups = groups.map do |old_group|
134
+ group = Import::Group.new(
135
+ name: old_group.name,
136
+ teams: old_group.teams.map {|team| team_mapping[team] }
137
+ )
138
+ group
139
+ end
140
+ puts "groups:"
141
+ pp groups
125
142
 
126
- pp rounds
127
- pp groups
143
+ ## fix
144
+ ## !! ERROR - no (cached) team rec found for team in group >Group A<
145
+ ## for >#<Sports::Club:0x000002c7e1686040><
146
+ ### update sync group to check for records (use .name) !!!
128
147
 
129
148
 
130
149
  ######################################################
@@ -166,10 +185,10 @@ class MatchReader ## todo/check: rename to MatchReaderV2 (use plural?) why? w
166
185
  ## e.g. group.teams assumes an array of team names e.g.
167
186
  ## ["Spain", "Czech Republic", "Turkey", "Croatia"]
168
187
  group_team_ids = []
169
- group.teams.each do |team_name|
170
- team_rec = cache_team_recs[ team_name ]
188
+ group.teams.each do |team|
189
+ team_rec = cache_team_recs[ team.name ]
171
190
  if team_rec.nil? ## assume team MUST always be present/known in mapping (via autoconfig parser)
172
- puts "!! ERROR - no (cached) team rec found for team in group >#{group.name}< for >#{team_name}<"
191
+ puts "!! ERROR - no (cached) team rec found for team in group >#{group.name}< for >#{team}<"
173
192
  exit 1
174
193
  end
175
194
  group_team_ids << team_rec.id
@@ -182,6 +201,7 @@ class MatchReader ## todo/check: rename to MatchReaderV2 (use plural?) why? w
182
201
  round_rec = Sync::Round.find_or_create( round, event: event_rec ) ## check: use/rename to EventRound why? why not?
183
202
  end
184
203
 
204
+
185
205
  matches.each do |match|
186
206
  ## note: pass along stage (if present): stage - optional from heading!!!!
187
207
  match = match.update( stage: stage ) if stage
@@ -5,7 +5,7 @@ module Readers
5
5
 
6
6
  MAJOR = 1 ## todo: namespace inside version or something - why? why not??
7
7
  MINOR = 2
8
- PATCH = 0
8
+ PATCH = 1
9
9
  VERSION = [MAJOR,MINOR,PATCH].join('.')
10
10
 
11
11
  def self.version
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: 1.2.0
4
+ version: 1.2.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: 2024-06-23 00:00:00.000000000 Z
11
+ date: 2024-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sportdb-sync
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2.0
19
+ version: 1.2.2
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.2.0
26
+ version: 1.2.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rdoc
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -93,7 +93,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 2.2.2
96
+ version: 3.1.0
97
97
  required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  requirements:
99
99
  - - ">="