Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

deutsche bundesliga, first draft

  • Loading branch information...
commit 004bb6fa05c7a13226f8ede2805ebea11aefd96b 1 parent dcb9df5
@geraldb geraldb authored
View
47 README.md
@@ -45,14 +45,61 @@ The `sport.db` includes the following tables:
[tbd]
+ CREATE TABLE teams (
+ id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
+ title VARCHAR( 255 ) NOT NULL,
+ title2 VARCHAR( 255 ),
+ [key] VARCHAR( 255 ) NOT NULL,
+ tag VARCHAR( 255 ),
+ created_at DATETIME NOT NULL,
+ updated_at DATETIME NOT NULL
+ );
+
+
### `games` Table
[tbd]
+ CREATE TABLE games (
+ id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
+ round_id INTEGER NOT NULL,
+ pos INTEGER NOT NULL,
+ group_id INTEGER,
+ team1_id INTEGER NOT NULL,
+ team2_id INTEGER NOT NULL,
+ play_at DATETIME NOT NULL,
+ knockout BOOLEAN DEFAULT 'f' NOT NULL,
+ home BOOLEAN DEFAULT 't' NOT NULL,
+ score1 INTEGER,
+ score2 INTEGER,
+ score3 INTEGER,
+ score4 INTEGER,
+ score5 INTEGER,
+ score6 INTEGER,
+ next_game_id INTEGER,
+ prev_game_id INTEGER,
+ toto12x VARCHAR( 255 ),
+ [key] VARCHAR( 255 ),
+ created_at DATETIME NOT NULL,
+ updated_at DATETIME NOT NULL
+ );
+
+
### `events` Table
[tbd]
+ CREATE TABLE events (
+ id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
+ title VARCHAR( 255 ) NOT NULL,
+ [key] VARCHAR( 255 ) NOT NULL,
+ start_at DATETIME NOT NULL,
+ created_at DATETIME NOT NULL,
+ updated_at DATETIME NOT NULL
+ );
+
+
+
## Command Line Tool
View
10 db/at/2012_13/bl.rb
@@ -139,11 +139,11 @@
]
games_bl11 = [
- [ 1, wac, [], ried, Time.cet('2012-10-06 00:00') ],
- [ 2, rapid, [], neustadt, Time.cet('2012-10-06 00:00') ],
- [ 3, mattersburg, [], salzburg, Time.cet('2012-10-06 00:00') ],
- [ 4, sturm, [], austria, Time.cet('2012-10-06 00:00') ],
- [ 5, admira, [], wacker, Time.cet('2012-10-06 00:00') ]
+ [ 1, wac, [2,5], ried, Time.cet('2012-10-06 00:00') ],
+ [ 2, rapid, [1,1], neustadt, Time.cet('2012-10-06 00:00') ],
+ [ 3, mattersburg, [1,3], salzburg, Time.cet('2012-10-06 00:00') ],
+ [ 4, sturm, [1,1], austria, Time.cet('2012-10-06 00:00') ],
+ [ 5, admira, [4,1], wacker, Time.cet('2012-10-06 00:00') ]
]
games_bl12 = [
View
62 db/de/2012_13/bl.rb
@@ -0,0 +1,62 @@
+# encoding: utf-8
+
+# note: timezone for games (play_at) is *always* CET (central european time)
+
+######################################
+## Deutsche Bundesliga 2012/13
+##
+## more info => ???
+
+
+bl = Event.create!( :key => 'de.2012/13',
+ :title => 'Deutsche Bundesliga 2012/13',
+ :start_at => Time.cet('2012-07-21 00:00') )
+
+
+bayern = Team.find_by_key!( 'bayern' )
+frankfurt = Team.find_by_key!( 'frankfurt' )
+schalke = Team.find_by_key!( 'schalke' )
+dortmund = Team.find_by_key!( 'dortmund' )
+hannover = Team.find_by_key!( 'hannover' )
+leverkusen = Team.find_by_key!( 'leverkusen' )
+duesseldorf = Team.find_by_key!( 'duesseldorf' )
+hsv = Team.find_by_key!( 'hsv' )
+mainz = Team.find_by_key!( 'mainz' )
+mgladback = Team.find_by_key!( 'mgladback' )
+freiburg = Team.find_by_key!( 'freiburg' )
+bremen = Team.find_by_key!( 'bremen' )
+hoffenheim = Team.find_by_key!( 'hoffenheim' )
+nuernberg = Team.find_by_key!( 'nuernberg' )
+stuttgart = Team.find_by_key!( 'stuttgart' )
+augsburg = Team.find_by_key!( 'augsburg' )
+wolfsburg = Team.find_by_key!( 'wolfsburg' )
+fuerth = Team.find_by_key!( 'fuerth' )
+
+
+
+bl.teams << bayern
+bl.teams << frankfurt
+## todo: to be continued
+
+
+bl07 = Round.create!( :event => bl, :pos => 7, :title => '7. Runde', :title2 => '06.+07. Okt 2012 ??' )
+
+
+## todo: fix game dates
+
+games_bl07 = [
+ [ 1, augsburg, [3,1], bremen, Time.cet('2012-10-06 00:00') ],
+ [ 2, bayern, [2,0], hoffenheim, Time.cet('2012-10-06 00:00') ],
+ [ 3, schalke, [3,0], wolfsburg, Time.cet('2012-10-06 00:00') ],
+ [ 4, freiburg, [3,0], nuernberg, Time.cet('2012-10-06 00:00') ],
+ [ 5, mainz, [1,0], duesseldorf, Time.cet('2012-10-06 00:00') ],
+ [ 6, fuerth, [0,1], hsv, Time.cet('2012-10-06 00:00') ],
+ [ 7, mgladbach, [2,0], frankfurt, Time.cet('2012-10-06 00:00') ],
+ [ 8, stuttgart, [2,2], leverkusen, Time.cet('2012-10-06 00:00') ],
+ [ 9, hannover, [1,1], dortmund, Time.cet('2012-10-06 00:00') ]
+]
+
+
+Game.create_from_ary!( games_bl07, bl07 )
+
+Prop.create!( :key => 'db.de.bl.2012/13.version', :value => '1' )
View
32 db/de/teams.rb
@@ -0,0 +1,32 @@
+# encoding: utf-8
+
+## fix/todo:
+## bayern, schalke, etc. already defined in cl
+## change create to create_or_update or similar (check for name convention in Rails?)
+
+
+teams = [
+ [ 'bayern', 'FC Bayern' ],
+ [ 'frankfurt', 'E Frankfurt' ],
+ [ 'schalke', 'FC Schalke 04' ],
+ [ 'dortmund', 'B Dortmund' ],
+ [ 'hannover', 'Hannover 96' ],
+ [ 'leverkusen', 'B Leverkusen' ],
+ [ 'duesseldorf', 'F Düsseldorf' ],
+ [ 'hsv', 'Hamburger SV' ],
+ [ 'mainz', 'Mainz 05' ],
+ [ 'mgladback', 'B M gladbach' ],
+ [ 'freiburg', 'SC Freiburg' ],
+ [ 'bremen', 'W Bremen' ],
+ [ 'hoffenheim', 'Hoffenheim' ],
+ [ 'nuernberg', '1 FC Nürnberg' ],
+ [ 'stuttgart', 'VfB Stuttgart' ],
+ [ 'augsburg', 'FC Augsburg' ],
+ [ 'wolfsburg', 'VfL Wolfsburg' ],
+ [ 'fuerth', 'G Fuerth' ]
+]
+
+Team.create_from_ary!( teams )
+
+
+Prop.create!( :key => 'db.de.teams.version', :value => '1' )
View
9 script/lib/sportdb/models.rb
@@ -27,15 +27,6 @@ def self.create_from_ary!( teams )
Team.create!( attr )
end # each team
end
-
- def key
- #todo/fix: generate_key w/ on save callback
-
- # generate key if necessary (for debugging only - should be not null field!)
- value = read_attribute(:key)
- value = "?#{title.downcase.gsub( /\s/, '_').gsub( /[^a-z0-9_]/, '*' )}?" if value.blank?
- value
- end
end # class Team
View
104 sport.sql
@@ -1,5 +1,107 @@
-# add sport.db SQL Schema here
+CREATE TABLE teams (
+ id INTEGER PRIMARY KEY AUTOINCREMENT
+ NOT NULL,
+ title VARCHAR( 255 ) NOT NULL,
+ title2 VARCHAR( 255 ),
+ [key] VARCHAR( 255 ) NOT NULL,
+ tag VARCHAR( 255 ),
+ created_at DATETIME NOT NULL,
+ updated_at DATETIME NOT NULL
+);
+CREATE TABLE games (
+ id INTEGER PRIMARY KEY AUTOINCREMENT
+ NOT NULL,
+ round_id INTEGER NOT NULL,
+ pos INTEGER NOT NULL,
+ group_id INTEGER,
+ team1_id INTEGER NOT NULL,
+ team2_id INTEGER NOT NULL,
+ play_at DATETIME NOT NULL,
+ knockout BOOLEAN DEFAULT 'f'
+ NOT NULL,
+ home BOOLEAN DEFAULT 't'
+ NOT NULL,
+ score1 INTEGER,
+ score2 INTEGER,
+ score3 INTEGER,
+ score4 INTEGER,
+ score5 INTEGER,
+ score6 INTEGER,
+ next_game_id INTEGER,
+ prev_game_id INTEGER,
+ toto12x VARCHAR( 255 ),
+ [key] VARCHAR( 255 ),
+ created_at DATETIME NOT NULL,
+ updated_at DATETIME NOT NULL
+);
+
+
+CREATE TABLE events (
+ id INTEGER PRIMARY KEY AUTOINCREMENT
+ NOT NULL,
+ title VARCHAR( 255 ) NOT NULL,
+ [key] VARCHAR( 255 ) NOT NULL,
+ start_at DATETIME NOT NULL,
+ created_at DATETIME NOT NULL,
+ updated_at DATETIME NOT NULL
+);
+
+
+CREATE TABLE events_teams (
+ id INTEGER PRIMARY KEY AUTOINCREMENT
+ NOT NULL,
+ event_id INTEGER NOT NULL,
+ team_id INTEGER NOT NULL,
+ created_at DATETIME NOT NULL,
+ updated_at DATETIME NOT NULL
+);
+
+
+CREATE TABLE groups (
+ id INTEGER PRIMARY KEY AUTOINCREMENT
+ NOT NULL,
+ event_id INTEGER NOT NULL,
+ title VARCHAR( 255 ) NOT NULL,
+ pos INTEGER NOT NULL,
+ created_at DATETIME NOT NULL,
+ updated_at DATETIME NOT NULL
+);
+
+
+CREATE TABLE groups_teams (
+ id INTEGER PRIMARY KEY AUTOINCREMENT
+ NOT NULL,
+ group_id INTEGER NOT NULL,
+ team_id INTEGER NOT NULL,
+ created_at DATETIME NOT NULL,
+ updated_at DATETIME NOT NULL
+);
+
+
+CREATE TABLE rounds (
+ id INTEGER PRIMARY KEY AUTOINCREMENT
+ NOT NULL,
+ event_id INTEGER NOT NULL,
+ title VARCHAR( 255 ) NOT NULL,
+ title2 VARCHAR( 255 ),
+ pos INTEGER NOT NULL,
+ playoff BOOLEAN DEFAULT 'f'
+ NOT NULL,
+ created_at DATETIME NOT NULL,
+ updated_at DATETIME NOT NULL
+);
+
+
+CREATE TABLE props (
+ id INTEGER PRIMARY KEY AUTOINCREMENT
+ NOT NULL,
+ [key] VARCHAR( 255 ) NOT NULL,
+ value VARCHAR( 255 ) NOT NULL,
+ created_at DATETIME NOT NULL,
+ updated_at DATETIME NOT NULL
+);
+
Please sign in to comment.
Something went wrong with that request. Please try again.