sportdb-search 0.2.1 → 0.2.2
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/lib/sportdb/search/sport-leagues.rb +59 -5
- data/lib/sportdb/search/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d33c1d67c3bd9e033532f8d1cbc35496205d5893f45cb994a8979477cf27f98
|
4
|
+
data.tar.gz: ba689181ec0c9891a9c19c2c863357982a2457bf49fcfb132371c6db6539bf66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e15e6f286ff215fda7c30303acda75a5d142958602ac5860d59880717bd56677738e629c853af0932efd8cc76751b52051830e4b2a2e352ebca5720dd7d520f
|
7
|
+
data.tar.gz: 4f5dbd8d358d9faffe627b058852ac4522b41dbb7b9aab22b47e52a22e1cf8c2d5e06e74917a3be6a46be914d4804e9d3b2e1e03025468762fad5231dabf2ef3
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
|
2
2
|
module Sports
|
3
3
|
|
4
|
+
###
|
5
|
+
## todo - move LeaguePeriod to its own file!!!
|
6
|
+
## add note - do NOT use match/find_by_name for now
|
7
|
+
## might get romoved? why? why not?
|
8
|
+
## for name lookup use League.find_by( name: ) !!!
|
9
|
+
## use find_by( code:, season: ) !!!
|
10
|
+
|
4
11
|
|
5
12
|
class LeaguePeriod
|
6
13
|
def self._search() CatalogDb::Metal::LeaguePeriod; end
|
@@ -18,23 +25,61 @@ class LeaguePeriod
|
|
18
25
|
end
|
19
26
|
end
|
20
27
|
|
21
|
-
|
22
28
|
## all-in-one query (name or code)
|
23
29
|
def self.match( q, season: )
|
24
30
|
_search.match_by_name_or_code( q, season: season )
|
25
31
|
end
|
26
32
|
|
33
|
+
|
27
34
|
###############
|
28
35
|
### more deriv support functions / helpers
|
29
|
-
def self.
|
30
|
-
period =
|
31
|
-
|
32
|
-
|
36
|
+
def self.find_by_code( code, season: )
|
37
|
+
period = nil
|
38
|
+
recs = _search.match_by_code( code, season: season )
|
39
|
+
# pp m
|
40
|
+
|
41
|
+
if recs.empty?
|
42
|
+
## fall through/do nothing
|
43
|
+
elsif recs.size > 1
|
44
|
+
puts "** !!! ERROR - too many (code) matches (#{recs.size}) for league period >#{code}+#{season}<:"
|
45
|
+
pp recs
|
33
46
|
exit 1
|
47
|
+
else
|
48
|
+
period = recs[0]
|
34
49
|
end
|
50
|
+
|
35
51
|
period
|
36
52
|
end
|
37
53
|
|
54
|
+
def self.find_by_name( name, season: )
|
55
|
+
period = nil
|
56
|
+
recs = _search.match_by_name( name, season: season )
|
57
|
+
# pp m
|
58
|
+
|
59
|
+
if recs.empty?
|
60
|
+
## fall through/do nothing
|
61
|
+
elsif recs.size > 1
|
62
|
+
puts "** !!! ERROR - too many (name) matches (#{recs.size}) for league period >#{name}+#{season}<:"
|
63
|
+
pp recs
|
64
|
+
exit 1
|
65
|
+
else
|
66
|
+
period = recs[0]
|
67
|
+
end
|
68
|
+
|
69
|
+
period
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.find_by( name: nil, code: nil, season: )
|
73
|
+
if code && name.nil?
|
74
|
+
find_by_code( code, season: season )
|
75
|
+
elsif name && code.nil?
|
76
|
+
find_by_name( name, season: season )
|
77
|
+
else
|
78
|
+
raise ArgumentError, "LeaguePeriod.find_by - one (and only one arg) required - code: or name:"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
|
38
83
|
def self.find( q, season: )
|
39
84
|
period = nil
|
40
85
|
recs = match( q, season: season )
|
@@ -52,6 +97,15 @@ class LeaguePeriod
|
|
52
97
|
|
53
98
|
period
|
54
99
|
end
|
100
|
+
|
101
|
+
def self.find!( q, season: )
|
102
|
+
period = find( q, season: season )
|
103
|
+
if period.nil?
|
104
|
+
puts "** !!! ERROR - no league period found for >#{q}+#{season}<, add to leagues table; sorry"
|
105
|
+
exit 1
|
106
|
+
end
|
107
|
+
period
|
108
|
+
end
|
55
109
|
end # class LeaguePeriod
|
56
110
|
|
57
111
|
|