sportdb 0.7.2 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,10 +10,10 @@
10
10
  ## nb: three letter codes (tags) taken from official premierleague.com site
11
11
 
12
12
  teams = [
13
- [ 'chelsea', 'Chelsea|Chelsea FC|FC Chelsea|FC Chelsea ENG', 'CHE', 'city:london' ],
14
- [ 'manunited', 'Manchester United|Man Utd|Manchester U. ENG', 'MUN', 'city:manchester' ],
15
- [ 'mancity', 'Manchester City|Man City|Man. City ENG', 'MCI', 'city:manchester' ],
16
- [ 'arsenal', 'Arsenal|Arsenal FC|FC Arsenal|FC Arsenal ENG', 'ARS', 'city:london' ],
13
+ [ 'chelsea', 'Chelsea|Chelsea FC|FC Chelsea', 'CHE', 'city:london' ],
14
+ [ 'manunited', 'Manchester United|Man Utd|Manchester U.', 'MUN', 'city:manchester' ],
15
+ [ 'mancity', 'Manchester City|Man City|Man. City', 'MCI', 'city:manchester' ],
16
+ [ 'arsenal', 'Arsenal|Arsenal FC|FC Arsenal', 'ARS', 'city:london' ],
17
17
  [ 'everton', 'Everton|Everton FC|FC Everton', 'EVE', 'city:liverpool' ],
18
18
  [ 'tottenham', 'Tottenham Hotspur|Tottenham', 'TOT', 'city:london' ],
19
19
  [ 'westbrom', 'West Bromwich Albion|West Brom', 'WBA', 'city:westbrom' ],
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+
3
+
4
+ teams = [
5
+ [ 'barcelona', 'FC Barcelona', 'city:barcelona' ],
6
+ [ 'madrid', 'Real Madrid', 'city:madrid' ],
7
+ [ 'atletico', 'Atlético Madrid|Atletico Madrid', 'city:madrid' ],
8
+ [ 'malaga', 'FC Málaga|Malaga CF|CF Malaga', 'city:malaga' ],
9
+ [ 'valencia', 'FC Valencia|CF Valencia', 'city:valencia' ],
10
+ [ 'athletic', 'Athletic Bilbao', 'city:bilbao' ]
11
+ ]
12
+
13
+ es = Country.find_by_key!( 'es' )
14
+
15
+ Team.create_from_ary!( teams, club: true, country: es )
16
+
17
+ Prop.create!( key: 'db.es.teams.version', value: '1' )
@@ -54,6 +54,7 @@ League.create_from_ary!( leagues_club_intl, club: true )
54
54
 
55
55
  leagues_intl = [
56
56
  [ 'euro', 'Euro' ],
57
+ [ 'america', 'Copa América' ],
57
58
  [ 'wm', 'World Cup' ], ## change key to world??
58
59
  [ 'wmq.euro', 'World Cup Quali Europe' ],
59
60
  [ 'wmq.america', 'World Cup Quali North/Central America and Caribbean' ]
@@ -4,103 +4,103 @@
4
4
 
5
5
  1 Runde / Jornada 1 // 20, 21 y 22 de julio
6
6
 
7
- jaguares - tigres 2012-07-20 19:30
8
- tijuana - puebla 2012-07-20 21:30
9
- cruzazul - monarcas 2012-07-21 17:00
10
- queretaro - leon 2012-07-21 17:00
11
- slaguna - sanluis 2012-07-21 19:00
12
- monterrey - america 2012-07-21 19:00
13
- atlas - pumas 2012-07-21 21:00
14
- toluca - chivas 2012-07-22 12:00
15
- atlante - pachuca 2012-07-22 18:00
7
+ jaguares 0:4 tigres 2012-07-20 19:30
8
+ tijuana 2:0 puebla 2012-07-20 21:30
9
+ cruzazul 0:0 monarcas 2012-07-21 17:00
10
+ queretaro 0:2 leon 2012-07-21 17:00
11
+ slaguna 2:1 sanluis 2012-07-21 19:00
12
+ monterrey 0:0 america 2012-07-21 19:00
13
+ atlas 1:1 pumas 2012-07-21 21:00
14
+ toluca 2:1 chivas 2012-07-22 12:00
15
+ atlante 0:0 pachuca 2012-07-22 18:00
16
16
 
17
17
 
18
18
  2 Runde / Jornada 2 // 27, 28 y 29 de julio
19
19
 
20
- monarcas - monterrey 2012-07-27 19:30
21
- leon - tijuana 2012-07-27 21:30
22
- america - jaguares 2012-07-28 17:00
23
- pachuca - atlas 2012-07-28 19:00
24
- tigres - atlante 2012-07-28 19:00
25
- sanluis - cruzazul 2012-07-28 21:00
26
- puebla - toluca 2012-07-29 12:00
27
- pumas - queretaro 2012-07-29 12:00
28
- chivas - slaguna 2012-07-29 17:00
20
+ monarcas 1:0 monterrey 2012-07-27 19:30
21
+ leon 4:0 tijuana 2012-07-27 21:30
22
+ america 4:2 jaguares 2012-07-28 17:00
23
+ pachuca 0:3 atlas 2012-07-28 19:00
24
+ tigres 2:1 atlante 2012-07-28 19:00
25
+ sanluis 1:2 cruzazul 2012-07-28 21:00
26
+ puebla 1:3 toluca 2012-07-29 12:00
27
+ pumas 3:0 queretaro 2012-07-29 12:00
28
+ chivas 0:1 slaguna 2012-07-29 17:00
29
29
 
30
30
 
31
31
  3 Runde / Jornada 3 // 3, 4, y 5 de agosto
32
32
 
33
- slaguna - puebla 2012-08-03 19:00
34
- tijuana - pumas 2012-08-03 19:30
35
- monarcas - sanluis 2012-08-03 21:30
36
- cruzazul - chivas 2012-08-04 17:00
37
- queretaro - pachuca 2012-08-04 17:00
38
- monterrey - jaguares 2012-08-04 19:00
39
- atlas - tigres 2012-08-04 21:00
40
- toluca - leon 2012-08-05 12:00
41
- atlante - america 2012-08-05 18:00
33
+ slaguna 2:2 puebla 2012-08-03 19:00
34
+ tijuana 1:0 pumas 2012-08-03 19:30
35
+ monarcas 3:3 sanluis 2012-08-03 21:30
36
+ cruzazul 0:0 chivas 2012-08-04 17:00
37
+ queretaro 0:1 pachuca 2012-08-04 17:00
38
+ monterrey 2:1 jaguares 2012-08-04 19:00
39
+ atlas 0:0 tigres 2012-08-04 21:00
40
+ toluca 2:1 leon 2012-08-05 12:00
41
+ atlante 2:2 america 2012-08-05 18:00
42
42
 
43
43
 
44
44
  4 Runde / Jornada 4 // 10, 11 y 12 de agosto
45
45
 
46
- jaguares - atlante 2012-08-10 19:30
47
- leon - slaguna 2012-08-10 21:30
48
- america - atlas 2012-08-11 17:00
49
- pachuca - tijuana 2012-08-11 19:00
50
- tigres - queretaro 2012-08-11 19:00
51
- sanluis - monterrey 2012-08-11 21:00
52
- puebla - cruzazul 2012-08-12 12:00
53
- pumas - toluca 2012-08-12 12:00
54
- chivas - monarcas 2012-08-12 17:00
46
+ jaguares 1:2 atlante 2012-08-10 19:30
47
+ leon 3:0 slaguna 2012-08-10 21:30
48
+ america 1:1 atlas 2012-08-11 17:00
49
+ pachuca 2:2 tijuana 2012-08-11 19:00
50
+ tigres 2:2 queretaro 2012-08-11 19:00
51
+ sanluis 1:1 monterrey 2012-08-11 21:00
52
+ puebla 0:1 cruzazul 2012-08-12 12:00
53
+ pumas 1:2 toluca 2012-08-12 12:00
54
+ chivas 1:1 monarcas 2012-08-12 17:00
55
55
 
56
56
 
57
57
  5 Runde / Jornada 5 // 17, 18 y 19 de agosto
58
58
 
59
- tijuana - tigres 2012-08-17 19:30
60
- monarcas - puebla 2012-08-17 21:30
61
- cruzazul - leon 2012-08-17 21:30
62
- queretaro - america 2012-08-18 17:00
63
- slaguna - pumas 2012-08-18 19:00
64
- monterrey - atlante 2012-08-18 19:00
65
- sanluis - chivas 2012-08-18 21:00
66
- atlas - jaguares 2012-08-18 21:00
67
- toluca - pachuca 2012-08-19 12:00
59
+ tijuana 2:1 tigres 2012-08-17 19:30
60
+ monarcas 3:0 puebla 2012-08-17 21:30
61
+ cruzazul 1:1 leon 2012-08-17 21:30
62
+ queretaro 0:4 america 2012-08-18 17:00
63
+ slaguna 1:2 pumas 2012-08-18 19:00
64
+ monterrey 1:1 atlante 2012-08-18 19:00
65
+ sanluis 0:1 chivas 2012-08-18 21:00
66
+ atlas 1:1 jaguares 2012-08-18 21:00
67
+ toluca 1:0 pachuca 2012-08-19 12:00
68
68
 
69
69
 
70
70
  6 Runde / Jornada 6 // 24, 25 y 26 de agosto
71
71
 
72
- jaguares - queretaro 2012-08-24 19:30
73
- leon - monarcas 2012-08-24 21:30
74
- america - tijuana 2012-08-25 17:00
75
- pachuca - slaguna 2012-08-25 19:00
76
- tigres - toluca 2012-08-25 19:00
77
- puebla - sanluis 2012-08-26 12:00
78
- pumas - cruzazul 2012-08-26 12:00
79
- chivas - monterrey 2012-08-26 17:00
80
- atlante - atlas 2012-08-26 18:00
72
+ jaguares 2:1 queretaro 2012-08-24 19:30
73
+ leon 1:3 monarcas 2012-08-24 21:30
74
+ america 0:1 tijuana 2012-08-25 17:00
75
+ pachuca 0:0 slaguna 2012-08-25 19:00
76
+ tigres 1:1 toluca 2012-08-25 19:00
77
+ puebla 1:0 sanluis 2012-08-26 12:00
78
+ pumas 0:1 cruzazul 2012-08-26 12:00
79
+ chivas 1:2 monterrey 2012-08-26 17:00
80
+ atlante 1:0 atlas 2012-08-26 18:00
81
81
 
82
82
 
83
83
  7 Runde / Jornada 7 // 31 de agosto, 1 y 2 de septiembre
84
84
 
85
- tijuana - jaguares 2012-08-31 19:30
86
- monarcas - pumas 2012-08-31 21:30
87
- cruzazul - pachuca 2012-09-01 17:00
88
- queretaro - atlante 2012-09-01 17:00
89
- slaguna - tigres 2012-09-01 19:00
90
- monterrey - atlas 2012-09-01 19:00
91
- sanluis - leon 2012-09-01 21:00
92
- toluca - america 2012-09-02 12:00
93
- chivas - puebla 2012-09-02 17:00
85
+ tijuana 2:0 jaguares 2012-08-31 19:30
86
+ monarcas 0:1 pumas 2012-08-31 21:30
87
+ cruzazul 1:1 pachuca 2012-09-01 17:00
88
+ queretaro 0:1 atlante 2012-09-01 17:00
89
+ slaguna 3:1 tigres 2012-09-01 19:00
90
+ monterrey 1:1 atlas 2012-09-01 19:00
91
+ sanluis 0:2 leon 2012-09-01 21:00
92
+ toluca 1:1 america 2012-09-02 12:00
93
+ chivas 1:1 puebla 2012-09-02 17:00
94
94
 
95
95
 
96
96
  8 Runde / Jornada 8 // 14, 15 y 16 de septiembre
97
97
 
98
- jaguares - toluca 2012-09-14 19:30
99
- pachuca - monarcas 2012-09-14 19:30
100
- leon - chivas 2012-09-14 21:30
101
- america - slaguna 2012-09-15 17:00
102
- tigres - cruzazul 2012-09-15 19:00
103
- atlas - queretaro 2012-09-15 21:00
104
- puebla - monterrey 2012-09-16 12:00
105
- pumas - sanluis 2012-09-16 12:00
106
- atlante - tijuana 2012-09-16 18:00
98
+ jaguares 2:0 toluca 2012-09-14 19:30
99
+ pachuca 3:2 monarcas 2012-09-14 19:30
100
+ leon 1:2 chivas 2012-09-14 21:30
101
+ america 2:0 slaguna 2012-09-15 17:00
102
+ tigres 2:0 cruzazul 2012-09-15 19:00
103
+ atlas 0:0 queretaro 2012-09-15 21:00
104
+ puebla 2:3 monterrey 2012-09-16 12:00
105
+ pumas 0:1 sanluis 2012-09-16 12:00
106
+ atlante 1:2 tijuana 2012-09-16 18:00
@@ -1,22 +1,22 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  teams = [
4
- [ 'america', 'Club América', 'city:mexico' ],
4
+ [ 'america', 'Club América|America de Mexico', 'city:mexico' ],
5
5
  [ 'atlante', 'Atlante', 'city:cancun' ],
6
6
  [ 'atlas', 'Atlas', 'city:guadalajara' ],
7
7
  [ 'chivas', 'Guadalajara Chivas', 'city:guadalajara' ],
8
8
  [ 'cruzazul', 'Cruz Azul', 'city:mexico' ],
9
9
  [ 'jaguares', 'Jaguares de Chiapas', 'city:tuxtla' ],
10
- [ 'leon', 'Club León', 'city:leon' ],
11
- [ 'monarcas', 'Monarcas Morelia', 'city:morelia' ],
12
- [ 'monterrey', 'Monterrey', 'city:monterrey' ],
10
+ [ 'leon', 'Club León|Club Leon', 'city:leon' ],
11
+ [ 'monarcas', 'Monarcas Morelia|Atletico Monarcas Morelia', 'city:morelia' ],
12
+ [ 'monterrey', 'Monterrey|CF Monterrey ', 'city:monterrey' ],
13
13
  [ 'pachuca', 'Pachuca', 'city:pachuca' ],
14
14
  [ 'puebla', 'Puebla F.C. ', 'city:puebla' ],
15
15
  [ 'queretaro', 'Querétaro F.C.', 'city:queretaro' ],
16
16
  [ 'sanluis', 'Club San Luis', 'city:sanluispotosi' ],
17
17
  [ 'slaguna', 'Santos Laguna', 'city:torreon' ],
18
18
  [ 'tijuana', 'Club Tijuana', 'city:tijuana' ],
19
- [ 'toluca', 'Toluca', 'city:toluca' ],
19
+ [ 'toluca', 'Toluca|Deportivo Toluca', 'city:toluca' ],
20
20
  [ 'tigres', 'Tigres UANL', 'city:sannicolas' ],
21
21
  [ 'pumas', 'Pumas UNAM', 'city:mexico' ]
22
22
  ]
@@ -1,43 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
- ##############
4
- ## south america
5
-
6
- ar = Country.find_by_key!( 'ar' )
7
- br = Country.find_by_key!( 'br' )
8
- cl = Country.find_by_key!( 'cl' )
9
- py = Country.find_by_key!( 'py' )
10
- uy = Country.find_by_key!( 'uy' )
11
-
12
- teams_america1 = [
13
- [ 'arg', 'Argentinien', 'ARG', ar ],
14
- [ 'bra', 'Brasilien', 'BRA', br ],
15
- [ 'chi', 'Chile', 'CHI', cl ],
16
- [ 'par', 'Paraguay', 'PAR', py ],
17
- [ 'uru', 'Uruguay', 'URU', uy ]
18
- ]
19
-
20
-
21
- #####################
22
- #### north/central america & caribbean islands
23
-
24
- mx = Country.find_by_key!( 'mx' )
25
- us = Country.find_by_key!( 'us' )
26
- hn = Country.find_by_key!( 'hn' )
27
- cr = Country.find_by_key!( 'cr' )
28
- sv = Country.find_by_key!( 'sv' )
29
- gy = Country.find_by_key!( 'gy' )
30
-
31
- teams_america2 = [
32
- [ 'mex', 'Mexiko', 'MEX', mx ],
33
- [ 'usa', 'Vereinigte Staaten|United States', 'USA', us ],
34
- [ 'hon', 'Honduras', 'HON', hn ],
35
- [ 'crc', 'Costa Rica', 'CRC', cr ],
36
- [ 'slv', 'El Salvador', 'SLV', sv ],
37
- [ 'guy', 'Guyana', 'GUY', gy ],
38
- ]
39
-
40
-
41
3
  ########################
42
4
  ## africa
43
5
 
@@ -82,7 +44,7 @@ teams_oceania = [
82
44
  [ 'nzl', 'Neuseeland', 'NZL', nz ]
83
45
  ]
84
46
 
85
- teams = teams_america1 + teams_america2 + teams_africa + teams_asia + teams_oceania
47
+ teams = teams_africa + teams_asia + teams_oceania
86
48
 
87
49
  Team.create_from_ary!( teams, national: true )
88
50
 
@@ -57,7 +57,70 @@ module SportDB
57
57
  def self.main
58
58
  Runner.new.run(ARGV)
59
59
  end
60
-
60
+
61
+ def self.create
62
+ CreateDB.up
63
+ end
64
+
65
+ def self.fixtures_rb # all builtin ruby fixtures; helper for covenience
66
+ ['leagues',
67
+ 'seasons',
68
+ 'at/teams',
69
+ 'at/badges',
70
+ 'at/2011_12/bl',
71
+ 'at/2011_12/cup',
72
+ 'at/2012_13/bl',
73
+ 'at/2012_13/cup',
74
+ 'de/teams',
75
+ 'en/teams',
76
+ 'es/teams',
77
+ 'cl/teams',
78
+ 'cl/badges',
79
+ 'cl/2011_12/cl',
80
+ 'cl/2011_12/el',
81
+ 'cl/2012_13/cl',
82
+ 'de/2012_13/bl',
83
+ 'en/2012_13/pl',
84
+ 'euro/teams',
85
+ 'euro/2008',
86
+ 'euro/2012',
87
+ 'america/teams',
88
+ 'america/2011',
89
+ 'copa/teams',
90
+ 'copa/sud_2012_13',
91
+ 'mx/teams',
92
+ 'mx/apertura_2012',
93
+ 'world/teams',
94
+ 'world/2010',
95
+ 'world/quali_2012_13_europe',
96
+ 'world/quali_2012_13_europe_c',
97
+ 'world/quali_2012_13_europe_i',
98
+ 'world/quali_2012_13_america',
99
+ 'nhl/teams']
100
+ end
101
+
102
+ def self.load_all
103
+ load( fixtures_rb )
104
+ end
105
+
106
+ def self.fixtures_txt
107
+ [['at.2011/12', 'at/2011_12/bl'],
108
+ ['at.2012/13', 'at/2012_13/bl'],
109
+ ['at.cup.2012/13', 'at/2012_13/cup'],
110
+ ['de.2012/13', 'de/2012_13/bl'],
111
+ ['en.2012/13', 'en/2012_13/pl'],
112
+ ['america.2011', 'america/2011'],
113
+ ['mx.apertura.2012', 'mx/apertura_2012'],
114
+ ['copa.sud.2012/13', 'copa/sud_2012_13'],
115
+ ['euro.2008', 'euro/2008'],
116
+ ['wm.2010', 'world/2010'],
117
+ ['wmq.euro', 'world/quali_2012_13_europe_c'],
118
+ ['wmq.america', 'world/quali_2012_13_america']]
119
+ end
120
+
121
+ def self.read_all
122
+ read( fixtures_txt )
123
+ end
61
124
 
62
125
  # load built-in (that is, bundled within the gem) named seeds
63
126
  # - pass in an array of seed names e.g. [ 'cl/teams', 'cl/2012_13/cl' ] etc.
@@ -106,9 +169,51 @@ module SportDB
106
169
 
107
170
  # delete ALL records (use with care!)
108
171
  def self.delete!
172
+ puts '*** deleting sport table records/data...'
109
173
  Deleter.new.run
110
174
  end # method delete!
111
175
 
176
+
177
+ class Stats
178
+ include SportDB::Models
179
+
180
+ def tables
181
+ puts "Stats:"
182
+ puts " #{Event.count} events / #{Round.count} rounds / #{Group.count} groups"
183
+ puts " #{League.count} leagues / #{Season.count} seasons"
184
+ puts " #{Country.count} countries / #{Region.count} regions / #{City.count} cities"
185
+ puts " #{Team.count} teams"
186
+ puts " #{Game.count} games"
187
+ puts " #{Badge.count} badges"
188
+
189
+ ## todo: add tags / taggings from worlddb
190
+ end
191
+
192
+ def props
193
+ puts "Props:"
194
+ Prop.order( 'created_at asc' ).all.each do |prop|
195
+ puts " #{prop.key} / #{prop.value} || #{prop.created_at}"
196
+ end
197
+ end
198
+ end
199
+
200
+ def self.stats
201
+ stats = Stats.new
202
+ stats.tables
203
+ stats.props
204
+ end
205
+
206
+ def self.tables
207
+ Stats.new.tables
208
+ end
209
+
210
+ def self.props
211
+ Stats.new.props
212
+ end
213
+
214
+
215
+
216
+
112
217
  def self.load_plugins
113
218
 
114
219
  @found ||= []
@@ -145,6 +250,6 @@ module SportDB
145
250
  end # module SportDB
146
251
 
147
252
 
148
- SportDB::load_plugins
253
+ ## SportDB::load_plugins
149
254
 
150
255
  SportDB.main if __FILE__ == $0
@@ -11,6 +11,25 @@ class Opts
11
11
  @create == true
12
12
  end
13
13
 
14
+ def setup=(boolean)
15
+ @setup = boolean
16
+ end
17
+
18
+ def setup?
19
+ return false if @setup.nil? # default setup flag is false
20
+ @setup == true
21
+ end
22
+
23
+ def sport=(boolean)
24
+ @sport = boolean
25
+ end
26
+
27
+ def sport?
28
+ return false if @sport.nil? # default sport flag is false
29
+ @sport == true
30
+ end
31
+
32
+
14
33
  def world=(boolean)
15
34
  @world = boolean
16
35
  end