sportdb-catalogs 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -1
- data/Rakefile +1 -1
- data/lib/sportdb/catalogs/base.rb +23 -0
- data/lib/sportdb/catalogs/event_info.rb +6 -5
- data/lib/sportdb/catalogs/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b593473df2d17fc60175c907bf78b0794f3bc26a6234cc247d58e788f8850ec
|
4
|
+
data.tar.gz: 0a9f535f23da1d3da21173d1c7d7588188e287b299c448f47bb8fa0cf9e33aa7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 927b572cef955abbc720ce43b4fab2cff7ac3f1eaae1514069302421d4172dcb96d3b02e96d36141a900f19e12efe1a820e44881e9a43ad3eeae983c8166f060
|
7
|
+
data.tar.gz: 7058a7524a1381e28b46586db1fd0b93d35ebbd807d2b75a20b2ef6071bdf738ad3db0bb3f142c83632c0b4203c42da314e6e7b6bfbcfcbf9741c7ab3f89083d
|
data/CHANGELOG.md
CHANGED
data/Rakefile
CHANGED
@@ -22,7 +22,7 @@ Hoe.spec 'sportdb-catalogs' do
|
|
22
22
|
self.extra_deps = [
|
23
23
|
['sportdb-structs', '>= 0.3.1'],
|
24
24
|
['sqlite3'], ## add sqlite for "metal" use (no activerecord etc.)
|
25
|
-
['footballdb-data'] ## add builtin default db
|
25
|
+
['footballdb-data', '>= 2024.8.23'] ## add builtin default db
|
26
26
|
]
|
27
27
|
|
28
28
|
self.spec_extras = {
|
@@ -155,6 +155,29 @@ def self._city( city )
|
|
155
155
|
city ## (re)use city struct - no need to run lookup again
|
156
156
|
end
|
157
157
|
end
|
158
|
+
|
159
|
+
|
160
|
+
def self._league( league )
|
161
|
+
if league.is_a?( String ) || league.is_a?( Symbol )
|
162
|
+
# note: query/find country via catalog db
|
163
|
+
## only query by code - why? why not?
|
164
|
+
recs = League.match_by_name_or_code( league )
|
165
|
+
if recs.empty?
|
166
|
+
puts "** !!! ERROR !!! - unknown league >#{league}< - no match found, sorry"
|
167
|
+
exit 1
|
168
|
+
elsif recs.size > 1
|
169
|
+
puts "** !!! ERROR !!! - league >#{league}< - too many matches found (#{recs.size}), sorry"
|
170
|
+
pp recs
|
171
|
+
exit 1
|
172
|
+
end
|
173
|
+
recs[0]
|
174
|
+
else ## assume league struct
|
175
|
+
league ## (re)use league struct - no need to run lookup again
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
|
180
|
+
|
158
181
|
end # class Record
|
159
182
|
|
160
183
|
|
@@ -16,7 +16,10 @@ class EventInfo < Record
|
|
16
16
|
def self._build_event_info( row )
|
17
17
|
## note: cache structs by key (do NOT rebuild duplicates; reuse)
|
18
18
|
@cache ||= Hash.new
|
19
|
-
|
19
|
+
## note cache key MUST be unique!
|
20
|
+
## use league PLUS season (row[0] season only will NOT work)
|
21
|
+
key = "#{row[0]}_#{row[1]}"
|
22
|
+
@cache[ key ] ||= Sports::EventInfo.new(
|
20
23
|
league: _to_league( row[0] ),
|
21
24
|
season: Season.parse(row[1]),
|
22
25
|
teams: row[2],
|
@@ -29,8 +32,7 @@ class EventInfo < Record
|
|
29
32
|
|
30
33
|
|
31
34
|
def self.seasons( league )
|
32
|
-
league_key =
|
33
|
-
: league.key
|
35
|
+
league_key = _league( league ).key
|
34
36
|
|
35
37
|
rows = execute( <<-SQL )
|
36
38
|
SELECT #{self.columns.join(', ')}
|
@@ -43,8 +45,7 @@ SQL
|
|
43
45
|
|
44
46
|
|
45
47
|
def self.find_by( league:, season: )
|
46
|
-
league_key =
|
47
|
-
: league.key
|
48
|
+
league_key = _league( league ).key
|
48
49
|
season_key = season.is_a?( String ) ? Season.parse(season).key
|
49
50
|
: season.key
|
50
51
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb-catalogs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
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-08-
|
11
|
+
date: 2024-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sportdb-structs
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 2024.8.23
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 2024.8.23
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rdoc
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|