sportdb-models 1.19.0 → 1.19.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
  SHA1:
3
- metadata.gz: b1524cb3a76b16ce80f8b2d484b11f8ab11002f6
4
- data.tar.gz: 209a229871e299fab7ac5ca8b90765052fc7da5f
3
+ metadata.gz: 7bccadbad7c54602a83e586c0eda1e125a5cccd6
4
+ data.tar.gz: 5ae4f27e9bde5789e73422bc88bb09b58f659ac8
5
5
  SHA512:
6
- metadata.gz: a9c48d1be59422f7fb7726e6121e909aceb9dc3a2306caea036ea19a5a64ebd5f4f7ff828009bf23810f48884d26b970b0f63718fa46ff37e7649e78b3b20f98
7
- data.tar.gz: 3e77eb48eafbf666afc8a92e5f6ea7d9403e157745b8abb508367292910dc3a355324cacc8a236b434cc7936d90876ff3bff95f177686378c33c0a025cf058fe
6
+ metadata.gz: 03e5aff14e4f82d56d084315b3f9570bf9c560aae14bdbe317c8b877ec37ac8d454443732670a6160c33c135427ba6892c126ac77a47a8c5230dea360b4a7c18
7
+ data.tar.gz: bd3c9d78dc0cbb414ef5b99fe09e0fb1583f9dc1b79be38d1eee04ed6c9922aa09ba3f99560dd9d0363d0ecab9a469938ba41b8232198b4664e38cf6cd95021e
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require './lib/sportdb/version.rb'
4
4
 
5
5
  Hoe.spec 'sportdb-models' do
6
6
 
7
- self.version = SportDb::VERSION
7
+ self.version = SportDb::Module::Models::VERSION
8
8
 
9
9
  self.summary = "sportdb-models - sport.db schema 'n' models for easy (re)use"
10
10
  self.description = summary
@@ -156,4 +156,4 @@ end # module SportDb
156
156
 
157
157
 
158
158
  ## say hello
159
- puts SportDb.banner if defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG
159
+ puts SportDb::Module::Models.banner if defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG
@@ -4,8 +4,9 @@ module SportDb
4
4
 
5
5
 
6
6
  class Season < ActiveRecord::Base
7
-
7
+
8
8
  has_many :events
9
+ has_many :leagues, :through => :events
9
10
 
10
11
  end # class Season
11
12
 
@@ -9,18 +9,19 @@ def up
9
9
  create_table :teams do |t|
10
10
  t.string :key, null: false # import/export key
11
11
  t.string :title, null: false
12
- t.string :title2
12
+ t.string :title2 ## find a better name -why? why not? or remove?
13
13
  t.string :code # make it not null? - three letter code (short title)
14
- t.string :synonyms # comma separated list of synonyms
15
- t.references :country, null: false
16
- t.references :city # NB: city is optional (should be required for clubs e.g. non-national teams)
14
+ t.string :synonyms # comma separated list of synonyms - todo/fix: change to alt_names!!!
15
+ t.references :country, null: false, index: false
16
+ t.references :city , index: false # NB: city is optional (should be required for clubs e.g. non-national teams)
17
+ ## todo/fix: add optional district (in city)
17
18
  t.boolean :club, null: false, default: false # is it a club (not a national team)?
18
19
 
19
- t.integer :since # founding year
20
+ t.integer :since # founding year -fix change to start_year / founded - why? why not?
20
21
  t.string :address
21
22
  t.string :web
22
23
 
23
- t.references :assoc # optional: national football assoc(iation), for example - used for national teams
24
+ t.references :assoc, index: false # optional: national football assoc(iation), for example - used for national teams
24
25
 
25
26
  ### fix: remove and add virtual attribute in model instead
26
27
  t.boolean :national, null: false, default: false # is it a national selection team (not a club)?
@@ -36,8 +37,8 @@ create_table :grounds do |t|
36
37
  t.string :title, null: false
37
38
  t.string :synonyms # comma separated list of synonyms
38
39
 
39
- t.references :country, null: false
40
- t.references :city # todo: make city required ???
40
+ t.references :country, null: false, index: false
41
+ t.references :city, index: false # todo: make city required ???
41
42
 
42
43
  t.integer :since # founding year
43
44
  t.integer :capacity # attentence capacity e.g. 10_000 or 50_000 etc.
@@ -58,9 +59,9 @@ add_index :grounds, :key, unique: true
58
59
 
59
60
  # join table: person+game(team1+team2+event(season+league))
60
61
  create_table :goals do |t|
61
- t.references :person, null: false
62
- t.references :game, null: false
63
- t.references :team, null: false ## use integer instead w/ values 1 or 2 for team1 or team2 ?? why? why not?
62
+ t.references :person, null: false, index: false
63
+ t.references :game, null: false, index: false
64
+ t.references :team, null: false, index: false ## use integer instead w/ values 1 or 2 for team1 or team2 ?? why? why not?
64
65
 
65
66
  t.integer :minute
66
67
  t.integer :offset, null: false, default: 0 # e.g. 45' +3 or 90' +2
@@ -81,9 +82,9 @@ end
81
82
 
82
83
  # join table -> person+team+event(season+league)
83
84
  create_table :rosters do |t| # use squads as an alternative name? why? why not??
84
- t.references :person, null: false
85
- t.references :team, null: false
86
- t.references :event # make required?
85
+ t.references :person, null: false, index: false
86
+ t.references :team, null: false, index: false
87
+ t.references :event , index: false # make required?
87
88
  t.integer :pos, null: false
88
89
 
89
90
  t.timestamps
@@ -92,11 +93,21 @@ end
92
93
 
93
94
  create_table :events do |t|
94
95
  t.string :key, null: false # import/export key
95
- t.references :league, null: false
96
- t.references :season, null: false
97
- t.date :start_at, null: false # NB: only use date (w/o time)
98
- t.date :end_at # make it required??? # NB: only use date (w/o time)
96
+ t.references :league, null: false, index: false
97
+ t.references :season, null: false, index: false
98
+ t.date :start_at, null: false # NB: only use date (w/o time) - yes!!! split into two!!!!
99
+ t.date :end_at # make it required??? # NB: only use date (w/o time)
100
+
99
101
  t.boolean :team3, null: false, default: true ## e.g. Champions League has no 3rd place (only 1st and 2nd/final)
102
+ ## todo: add league/cup flag/flags or to league itself?
103
+ ## or add add a tournament type field - why? why not?
104
+
105
+ t.integer :num ## optional series counter e.g. World Cup No. 2, Bundesliga No. 43 etc. etc.
106
+
107
+ ## auto-added flag (e.g. start_at n end_at dates got calculated)
108
+ ## if auto-added flag is false - do NOT auto-update start_at, end_at etc.
109
+ t.boolean :auto, null: false, default: true
110
+
100
111
 
101
112
  #### track 1-n sources (from repos) - # todo move to its own table later
102
113
  ## NB: relative to event.yml - use mapper to "resolve" to full path w/ repo; use league+season keys
@@ -114,12 +125,17 @@ create_table :rounds do |t|
114
125
  t.references :event, null: false, index: false ## Note: do NOT auto-add index
115
126
  t.string :title, null: false
116
127
  t.string :title2
117
- t.integer :pos, null: false
128
+ t.integer :pos, null: false ## use only for "internal" sort order (defaults to insertion order)
129
+
130
+ t.integer :num ## optional match day/week number
131
+ t.string :key ## optional match day/week number key (as string)
132
+
118
133
  ## add new table stage/stages for grouping rounds in group rounds and playoff rounds, for example???
119
134
  ## # "regular" season (group) games or post-season (playoff) knockouts (k.o's)
120
135
  t.boolean :knockout, null: false, default: false
121
- t.date :start_at, null: false # NB: only use date (w/o time)
122
- t.date :end_at # todo: make it required e.g. :null => false # NB: only use date (w/o time)
136
+ ## todo: add leg (e.g. leg1, leg2, etc. why? why not?)
137
+ t.date :start_at # note: only use date (w/o time) - fix: change to start_date!!!
138
+ t.date :end_at # note: only use date (w/o time) - fix: change to end_date!!!
123
139
 
124
140
  ## auto-added flag (e.g. start_at n end_at dates got calculated)
125
141
  ## if auto-added flag is false - do NOT auto-update start_at, end_at etc.
@@ -134,7 +150,9 @@ add_index :rounds, :event_id # fk event_id index
134
150
  create_table :groups do |t| # Teamgruppe (zB Gruppe A, Gruppe B, etc.)
135
151
  t.references :event, null: false, index: false ## Note: do NOT auto-add index
136
152
  t.string :title, null: false
137
- t.integer :pos, null: false
153
+ t.integer :pos, null: false ## use only for "internal" sort order (defaults to insertion order)
154
+
155
+ t.string :key ## optional group key e.g. A, B, C or 1, 2, etc. - use why? why not?
138
156
  t.timestamps
139
157
  end
140
158
 
@@ -144,6 +162,7 @@ add_index :groups, :event_id # fk event_id index
144
162
  create_table :stages do |t| # e.g. regular season, champions round, etc.
145
163
  t.references :event, null: false, index: false ## Note: do NOT auto-add index
146
164
  t.string :title, null: false
165
+ ## todo/check: add pos for use only for "internal" sort order (defaults to insertion order)??
147
166
  t.timestamps
148
167
  end
149
168
 
@@ -152,27 +171,40 @@ add_index :stages, :event_id # fk event_id index
152
171
 
153
172
 
154
173
  ###########################
155
- # fix: rename table to matches
174
+ # fix: rename table to matches - why? why not?
156
175
  create_table :games do |t|
157
176
  t.string :key # import/export key
158
- t.references :round, null: false, index: false ## Note: do NOT auto-add index
159
- t.integer :pos, null: false
160
- t.references :group, index: false ## Note: do NOT auto-add index -- group is optional
161
- t.references :stage, index: false # optional - regular seasion / champions round etc.
177
+ t.references :event, null: false, index: false
178
+ t.integer :pos, null: false ## note: use only for "internal" sort order (defaults to insertion order)
179
+ t.integer :num ## optional - "event global" match number e.g. World Cup - Match 1, Match 2, etc.
162
180
  t.references :team1, null: false, index: false ## Note: do NOT auto-add index
163
181
  t.references :team2, null: false, index: false ## Note: do NOT auto-add index
164
182
 
165
- t.datetime :play_at, null: false
183
+ t.references :round, index: false ## Note: do NOT auto-add index
184
+ t.references :group, index: false ## Note: do NOT auto-add index -- group is optional
185
+ t.references :stage, index: false # optional - regular seasion / champions round etc.
186
+
187
+ ## "inline" helper keys auto-populate for easier "no-join/single-table" queries
188
+ t.string :team1_key
189
+ t.string :team2_key
190
+ t.string :event_key
191
+ t.string :round_key
192
+ t.integer :round_num ## e.g. 1,2,3 for match day/match week
193
+ t.string :group_key
194
+ t.string :stage_key
195
+
196
+
197
+ t.datetime :play_at # optioanl play date - todo/fix: split into play_date AND play_time!!!
166
198
  t.boolean :postponed, null: false, default: false
167
199
  t.datetime :play_at_v2 # optional old date (when postponed)
168
200
  t.datetime :play_at_v3 # optional odl date (when postponed twice)
169
201
 
170
- t.references :ground # optional - stadium (lets you get city,region,country,etc)
171
- t.references :city # optional - convenience for ground.city_id ???
202
+ t.references :ground, index: false # optional - stadium (lets you get city,region,country,etc)
203
+ t.references :city, index: false # optional - convenience for ground.city_id ???
172
204
 
173
205
 
174
206
  t.boolean :knockout, null: false, default: false
175
- t.boolean :home, null: false, default: true # is team1 play at home (that is, at its home stadium)
207
+ t.boolean :home, null: false, default: true # is team1 play at home or neutral (that is, at its home stadium)
176
208
  t.integer :score1
177
209
  t.integer :score2
178
210
  t.integer :score1et # extratime - team 1 (opt)
@@ -193,6 +225,7 @@ create_table :games do |t|
193
225
  end
194
226
 
195
227
  add_index :games, :key, unique: true
228
+ add_index :games, :event_id # fk event_id index
196
229
  add_index :games, :round_id # fk round_id index
197
230
  add_index :games, :group_id # fk group_id index
198
231
  add_index :games, :next_game_id # fk next_game_id index
@@ -248,31 +281,39 @@ add_index :groups_teams, :group_id
248
281
 
249
282
  ### todo: add models and some seed data
250
283
 
251
- create_table :seasons do |t| ## also used for years
284
+ create_table :seasons do |t| ## also used for years - add a boolean year true/false flag too - why? why not?
252
285
  t.string :key, null: false
253
286
  t.string :title, null: false # e.g. 2011/12, 2012/13 ### what to do w/ 2012? for world cup etc?
254
287
  t.timestamps
255
288
  end
256
289
 
290
+
257
291
  create_table :leagues do |t| ## also for cups/conferences/tournaments/world series/etc.
258
292
  t.string :key, null: false
259
293
  t.string :title, null: false # e.g. Premier League, Deutsche Bundesliga, World Cup, Champions League, etc.
260
- t.references :country ## optional for now , :null => false ### todo: create "virtual" country for international leagues e.g. use int? or world (ww?)/europe (eu)/etc. similar? already taken??
294
+ t.references :country, index: false ## optional for now , :null => false ### todo: create "virtual" country for international leagues e.g. use int? or world (ww?)/europe (eu)/etc. similar? already taken??
261
295
 
262
- ## fix: rename to :clubs from :club
296
+ ## fix: rename to :clubs from :club - why? why not?
297
+ ## fix: rename to :intl from :international - why? why not? shorter? better?
298
+ ## todo/check: flip clup to league flag? why? why not?
263
299
  t.boolean :club, null: false, default: false # club teams or national teams?
300
+ t.boolean :intl, null: false, default: false # national league or international?
301
+ t.boolean :cup, null: false, default: false ## or regular season league?? use a tournament type field with enums - why? why not?
302
+ t.integer :level ## use tier? e.g. level 1, level 2, etc.
303
+
304
+ ## todo/fix: add start_year / end_year ???
305
+
264
306
  ## todo: add t.boolean :national flag? for national teams?
265
- ## t.boolean :international, :null => false, :default => false # national league or international?
266
- ## t.boolean :cup ## or regular season league??
267
307
  t.timestamps
268
308
  end
269
309
 
310
+
270
311
  create_table :badges do |t|
271
- t.references :team, null: false
312
+ t.references :team, null: false, index: false
272
313
  ## todo/fix: use event insead of league+season ??
273
314
  ## t.references :event, :null => false # event => league+season
274
- t.references :league, null: false
275
- t.references :season, null: false
315
+ t.references :league, null: false, index: false
316
+ t.references :season, null: false, index: false
276
317
  t.string :title, null: false # Meister, Weltmeister, Europameister, Cupsieger, Vize-Meister, Aufsteiger, Absteiger, etc.
277
318
  t.timestamps
278
319
  end
@@ -286,7 +327,7 @@ create_table :assocs do |t|
286
327
  t.string :web
287
328
 
288
329
  ### if national assoc - has (optional) country ref
289
- t.references :country # note: optional - only used/set (required) for national assocs (or subnational too?)
330
+ t.references :country, index: false # note: optional - only used/set (required) for national assocs (or subnational too?)
290
331
  t.boolean :national, null: false, default: false
291
332
 
292
333
  ## add :world flag for FIFA? - just check if parent is null? for root assoc(s)? why? why not?
@@ -320,16 +361,16 @@ add_index :assocs_assocs, :assoc2_id
320
361
  # todo: add group_standings per round with pos diffs e.g +1,+2, -3 etc.
321
362
 
322
363
  create_table :group_standings do |t|
323
- t.references :group, null: false
364
+ t.references :group, null: false, index: false
324
365
  t.timestamps
325
366
  end
326
367
 
327
368
  ### use items instead of entries - why (shorter! simple plural e.g. just add s)
328
369
 
329
370
  create_table :group_standing_entries do |t|
330
- t.references :group_standing, null: false
331
- t.references :team, null: false
332
- t.integer :pos
371
+ t.references :group_standing, null: false, index: false
372
+ t.references :team, null: false, index: false
373
+ t.integer :pos ## todo/fix: add rank and use pos only for "internal" insertation order
333
374
  t.integer :played
334
375
  t.integer :won
335
376
  t.integer :lost
@@ -343,13 +384,13 @@ end
343
384
 
344
385
 
345
386
  create_table :event_standings do |t|
346
- t.references :event, null: false
387
+ t.references :event, null: false, index: false
347
388
  t.timestamps
348
389
  end
349
390
 
350
391
  create_table :event_standing_entries do |t|
351
- t.references :event_standing, null: false
352
- t.references :team, null: false
392
+ t.references :event_standing, null: false, index: false
393
+ t.references :team, null: false, index: false
353
394
  t.integer :pos
354
395
  t.integer :played
355
396
  t.integer :won
@@ -372,8 +413,8 @@ create_table :alltime_standings do |t|
372
413
  end
373
414
 
374
415
  create_table :alltime_standing_entries do |t|
375
- t.references :alltime_standing, null: false
376
- t.references :team, null: false
416
+ t.references :alltime_standing, null: false, index: false
417
+ t.references :team, null: false, index: false
377
418
  t.integer :pos
378
419
  t.integer :played # todo: use a different name - why? why not?
379
420
  t.integer :won
data/lib/sportdb/stats.rb CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  module SportDb
3
-
3
+
4
4
  class Stats
5
5
  include Models
6
6
 
@@ -16,10 +16,6 @@ module SportDb
16
16
 
17
17
  puts " #{Assoc.count} assocs|orgs"
18
18
  puts " #{Ground.count} grounds|stadiums"
19
-
20
- ## note: moved to racing.db -- remove/delete!!
21
- ## puts " #{Track.count} tracks / #{Race.count} races (track+event recs) / #{Run.count} runs"
22
- ## puts " #{Record.count} records (race|run+person recs)"
23
19
  end
24
20
 
25
21
  end # class Stats
@@ -1,10 +1,11 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module SportDb
4
-
4
+ module Module
5
+ module Models
5
6
  MAJOR = 1 ## todo: namespace inside version or something - why? why not??
6
7
  MINOR = 19
7
- PATCH = 0
8
+ PATCH = 1
8
9
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
10
 
10
11
  def self.version
@@ -19,4 +20,10 @@ module SportDb
19
20
  "#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
20
21
  end
21
22
 
23
+ end # module Models
24
+ end # module Module
25
+
26
+ #################
27
+ ## add convenience shortcuts
28
+ VERSION = Module::Models::VERSION
22
29
  end # module SportDb
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.19.0
4
+ version: 1.19.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: 2020-05-11 00:00:00.000000000 Z
11
+ date: 2020-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: worlddb-models