sportdb-catalogs 1.2.5 → 1.2.6
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 +2 -2
- data/lib/sportdb/catalogs/league.rb +82 -26
- data/lib/sportdb/catalogs/version.rb +1 -1
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 578a7aa88076914972bfeecf0bf244bcd33c2b14e22ba2032419d7d90aedd2d2
|
4
|
+
data.tar.gz: 755ff971b5e0dd2f63a91ffe6ed09dbaf96e856327c1a66f4531e55f91dd8e3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1883983c41e1cc509e0a2b939bc59c70896602d6fb1e3c3f8943fc4c67115f680d09d5813a37d6215c61062352a2fad13169255d7df032ecd6beb91730ab52fd
|
7
|
+
data.tar.gz: 3ffa1b429634885daad9e7f46e61c9c3d81f4b799edbe6591a9c49c5c8260d5ed5b37799825d720f3aff27ab420f0f65fdf6621a14cd8f978199839def029094
|
data/CHANGELOG.md
CHANGED
data/Rakefile
CHANGED
@@ -20,9 +20,9 @@ Hoe.spec 'sportdb-catalogs' do
|
|
20
20
|
self.licenses = ['Public Domain']
|
21
21
|
|
22
22
|
self.extra_deps = [
|
23
|
-
['sportdb-structs', '>= 0.
|
23
|
+
['sportdb-structs', '>= 0.5.0'],
|
24
|
+
['footballdb-data', '>= 2025.1.3'], ## add builtin default db
|
24
25
|
['sqlite3'], ## add sqlite for "metal" use (no activerecord etc.)
|
25
|
-
['footballdb-data', '>= 2024.8.23'] ## add builtin default db
|
26
26
|
]
|
27
27
|
|
28
28
|
self.spec_extras = {
|
@@ -44,44 +44,78 @@ SQL
|
|
44
44
|
)
|
45
45
|
end
|
46
46
|
|
47
|
+
|
48
|
+
def self._query_by_code( code: )
|
49
|
+
execute( <<-SQL )
|
50
|
+
SELECT #{self.columns.join(', ')}
|
51
|
+
FROM leagues
|
52
|
+
INNER JOIN league_codes ON leagues.key = league_codes.key
|
53
|
+
WHERE league_codes.code = '#{code}'
|
54
|
+
SQL
|
55
|
+
end
|
56
|
+
|
57
|
+
def self._query_by_code_and_country( code:, country: )
|
58
|
+
execute( <<-SQL )
|
59
|
+
SELECT #{self.columns.join(', ')}
|
60
|
+
FROM leagues
|
61
|
+
INNER JOIN league_codes ON leagues.key = league_codes.key
|
62
|
+
WHERE league_codes.code = '#{code}' AND
|
63
|
+
leagues.country_key = '#{country}'
|
64
|
+
SQL
|
65
|
+
end
|
66
|
+
|
67
|
+
def self._query_by_code_and_season( code:, start_yyyymm:,
|
68
|
+
end_yyyymm: )
|
69
|
+
execute( <<-SQL )
|
70
|
+
SELECT #{self.columns.join(', ')}
|
71
|
+
FROM leagues
|
72
|
+
WHERE leagues.key IN
|
73
|
+
(SELECT league_periods.key
|
74
|
+
FROM league_periods
|
75
|
+
INNER JOIN league_period_codes ON league_periods.id = league_period_codes.league_period_id
|
76
|
+
WHERE league_period_codes.code = '#{code}' AND
|
77
|
+
league_period_codes.start_yyyymm <= #{start_yyyymm} AND
|
78
|
+
league_period_codes.end_yyyymm >= #{end_yyyymm}
|
79
|
+
)
|
80
|
+
SQL
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
|
47
85
|
def self.match_by_code( code,
|
48
|
-
country: nil
|
86
|
+
country: nil,
|
87
|
+
season: nil )
|
49
88
|
## note: match must for now always include name
|
50
89
|
### todo/fix: allow special normalize formula for
|
51
90
|
## code - why? why not?
|
52
91
|
## e.g. allow ö1 or ö or such - why? why not?
|
53
92
|
code = normalize( code )
|
54
93
|
|
55
|
-
|
56
|
-
if country.nil?
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
INNER JOIN league_codes ON leagues.key = league_codes.key
|
75
|
-
WHERE league_codes.code = '#{code}' AND
|
76
|
-
leagues.country_key = '#{country_rec.key}'
|
77
|
-
|
78
|
-
SQL
|
79
|
-
end
|
94
|
+
|
95
|
+
rows = if country.nil? && season.nil?
|
96
|
+
## note: returns empty array if no match and NOT nil
|
97
|
+
_query_by_code( code: code )
|
98
|
+
elsif country && season.nil? ## filter by country
|
99
|
+
## note: also skip international leagues & cups (e.g. champions league etc.) for now - why? why not?
|
100
|
+
|
101
|
+
## note: country assumes / allows the country key or fifa code for now
|
102
|
+
## note: allow passing in of country struct too
|
103
|
+
country_rec = _country( country )
|
104
|
+
_query_by_code_and_country( code: code, country: country_rec.key )
|
105
|
+
elsif season && country.nil?
|
106
|
+
season = Season( season )
|
107
|
+
start_yyyymm, end_yyyymm = _calc_yyyymm( season )
|
108
|
+
_query_by_code_and_season( code: code, start_yyyymm: start_yyyymm,
|
109
|
+
end_yyyymm: end_yyyymm )
|
110
|
+
else
|
111
|
+
raise ArgumentError, "match_by_code - code and optional country or season expected"
|
112
|
+
end
|
80
113
|
|
81
114
|
## wrap results array into struct records
|
82
115
|
rows.map {|row| _build_league( row )}
|
83
116
|
end
|
84
117
|
|
118
|
+
|
85
119
|
def self.match_by_name( name,
|
86
120
|
country: nil )
|
87
121
|
## note: match must for now always include name
|
@@ -163,6 +197,28 @@ SQL
|
|
163
197
|
end
|
164
198
|
|
165
199
|
|
200
|
+
|
201
|
+
##############################################
|
202
|
+
# try match by code and seaons (via league_periods)
|
203
|
+
## todo/fix - move up for reuse (duplicated in league_period etc) - why? why not?
|
204
|
+
|
205
|
+
def self._calc_yyyymm( season )
|
206
|
+
start_yyyymm = if season.calendar?
|
207
|
+
"#{season.start_year}01".to_i
|
208
|
+
else
|
209
|
+
"#{season.start_year}07".to_i
|
210
|
+
end
|
211
|
+
|
212
|
+
end_yyyymm = if season.calendar?
|
213
|
+
"#{season.end_year}12".to_i
|
214
|
+
else
|
215
|
+
"#{season.end_year}06".to_i
|
216
|
+
end
|
217
|
+
|
218
|
+
[start_yyyymm, end_yyyymm]
|
219
|
+
end
|
220
|
+
|
221
|
+
|
166
222
|
end # class League
|
167
223
|
end # module Metal
|
168
224
|
end # module CatalogDb
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sportdb-structs
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.5.0
|
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: 0.
|
26
|
+
version: 0.5.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: footballdb-data
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 2025.1.3
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 2025.1.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: sqlite3
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '0'
|
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: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rdoc
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,14 +78,14 @@ dependencies:
|
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: '4.
|
81
|
+
version: '4.2'
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: '4.
|
88
|
+
version: '4.2'
|
89
89
|
description: sportdb-catalogs - sport.db (search 'n' find) catalogs for countries,
|
90
90
|
leagues, clubs, national teams, and more
|
91
91
|
email: gerald.bauer@gmail.com
|
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
133
|
- !ruby/object:Gem::Version
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|
136
|
-
rubygems_version: 3.
|
136
|
+
rubygems_version: 3.5.22
|
137
137
|
signing_key:
|
138
138
|
specification_version: 4
|
139
139
|
summary: sportdb-catalogs - sport.db (search 'n' find) catalogs for countries, leagues,
|