sportdb-models 1.19.0 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -20
- data/Manifest.txt +27 -38
- data/README.md +31 -31
- data/Rakefile +32 -32
- data/lib/sportdb/models.rb +212 -159
- data/lib/sportdb/{deleter.rb → models/deleter.rb} +3 -9
- data/lib/sportdb/models/formats.rb +23 -0
- data/lib/sportdb/models/models/assoc.rb +38 -0
- data/lib/sportdb/models/{badge.rb → models/badge.rb} +14 -14
- data/lib/sportdb/models/models/event.rb +55 -0
- data/lib/sportdb/models/{forward.rb → models/forward.rb} +55 -55
- data/lib/sportdb/models/{goal.rb → models/goal.rb} +15 -15
- data/lib/sportdb/models/models/ground.rb +16 -0
- data/lib/sportdb/models/{group.rb → models/group.rb} +10 -7
- data/lib/sportdb/models/models/league.rb +20 -0
- data/lib/sportdb/models/{roster.rb → models/lineup.rb} +17 -18
- data/lib/sportdb/models/{game.rb → models/match.rb} +18 -61
- data/lib/sportdb/models/{person.rb → models/person.rb} +21 -21
- data/lib/sportdb/models/{round.rb → models/round.rb} +1 -6
- data/lib/sportdb/models/{season.rb → models/season.rb} +15 -14
- data/lib/sportdb/models/{stage.rb → models/stage.rb} +9 -5
- data/lib/sportdb/models/{stats/alltime_standing_entry.rb → models/stats/alltime_standing.rb} +9 -1
- data/lib/sportdb/models/{stats/event_standing_entry.rb → models/stats/event_standing.rb} +31 -21
- data/lib/sportdb/models/{stats/group_standing_entry.rb → models/stats/group_standing.rb} +10 -1
- data/lib/sportdb/models/models/team.rb +56 -0
- data/lib/sportdb/models/{world → models/world}/city.rb +2 -2
- data/lib/sportdb/models/{world → models/world}/continent.rb +20 -20
- data/lib/sportdb/models/{world → models/world}/country.rb +0 -0
- data/lib/sportdb/models/{world → models/world}/state.rb +19 -19
- data/lib/sportdb/models/schema.rb +466 -0
- data/lib/sportdb/models/stats.rb +23 -0
- data/lib/sportdb/models/utils.rb +24 -24
- data/lib/sportdb/{version.rb → models/version.rb} +27 -22
- data/test/helper.rb +46 -42
- data/test/test_changes.rb +38 -38
- data/test/test_cursor.rb +15 -15
- data/test/test_winner.rb +75 -70
- metadata +39 -44
- data/lib/sportdb/calc.rb +0 -279
- data/lib/sportdb/models/assoc.rb +0 -106
- data/lib/sportdb/models/assoc_assoc.rb +0 -15
- data/lib/sportdb/models/event.rb +0 -66
- data/lib/sportdb/models/event_ground.rb +0 -15
- data/lib/sportdb/models/event_team.rb +0 -16
- data/lib/sportdb/models/ground.rb +0 -100
- data/lib/sportdb/models/group_team.rb +0 -14
- data/lib/sportdb/models/league.rb +0 -83
- data/lib/sportdb/models/stage_team.rb +0 -14
- data/lib/sportdb/models/stats/alltime_standing.rb +0 -44
- data/lib/sportdb/models/stats/event_standing.rb +0 -55
- data/lib/sportdb/models/stats/group_standing.rb +0 -50
- data/lib/sportdb/models/team.rb +0 -119
- data/lib/sportdb/models/team_compat.rb +0 -64
- data/lib/sportdb/patterns.rb +0 -37
- data/lib/sportdb/schema.rb +0 -397
- data/lib/sportdb/standings.rb +0 -178
- data/lib/sportdb/stats.rb +0 -27
@@ -5,7 +5,7 @@ module SportDb
|
|
5
5
|
######
|
6
6
|
# note: make models available in sportdb module by default with namespace
|
7
7
|
# e.g. lets you use Team instead of Model::Team
|
8
|
-
include
|
8
|
+
include Models
|
9
9
|
|
10
10
|
def run
|
11
11
|
# for now delete all tables
|
@@ -19,7 +19,7 @@ module SportDb
|
|
19
19
|
|
20
20
|
Goal.delete_all
|
21
21
|
|
22
|
-
|
22
|
+
Match.delete_all
|
23
23
|
Event.delete_all
|
24
24
|
EventTeam.delete_all
|
25
25
|
EventGround.delete_all
|
@@ -30,7 +30,7 @@ module SportDb
|
|
30
30
|
Round.delete_all
|
31
31
|
Badge.delete_all
|
32
32
|
|
33
|
-
|
33
|
+
Lineup.delete_all
|
34
34
|
|
35
35
|
Team.delete_all
|
36
36
|
|
@@ -41,12 +41,6 @@ module SportDb
|
|
41
41
|
|
42
42
|
Assoc.delete_all # associations / organizations
|
43
43
|
AssocAssoc.delete_all # associations / organizations
|
44
|
-
|
45
|
-
## note: moved to racing.db - delete/remove!!!
|
46
|
-
## Record.delete_all
|
47
|
-
## Run.delete_all
|
48
|
-
## Race.delete_all
|
49
|
-
## Track.delete_all
|
50
44
|
end
|
51
45
|
|
52
46
|
end # class Deleter
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module SportDb
|
4
|
+
|
5
|
+
# collection of regex patterns for reuse (SportDb specific)
|
6
|
+
|
7
|
+
### todo: add a patterns.md page to github ??
|
8
|
+
## - add regexper pics??
|
9
|
+
|
10
|
+
TEAM_KEY_RE = %r{ \A
|
11
|
+
[a-z_][a-z0-9_]*
|
12
|
+
\z}x
|
13
|
+
TEAM_KEY_MESSAGE = "expected one or more lowercase letters a-z (or 0-9 or _; must start with a-z or _)"
|
14
|
+
|
15
|
+
|
16
|
+
# must start w/ letter A-Z (2nd,3rd,4th or 5th can be number)
|
17
|
+
TEAM_CODE_RE = %r{ \A
|
18
|
+
[A-Z_][A-Z0-9_]*
|
19
|
+
\z}x
|
20
|
+
TEAM_CODE_MESSAGE = "expected one or more uppercase letters A-Z (or 0-9 or _; must start with A-Z or _)"
|
21
|
+
|
22
|
+
|
23
|
+
end # module SportDb
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module SportDb
|
2
|
+
module Model
|
3
|
+
|
4
|
+
class Assoc < ActiveRecord::Base
|
5
|
+
|
6
|
+
|
7
|
+
has_many :parent_assoc_assocs, class_name: 'AssocAssoc', foreign_key: 'assoc2_id'
|
8
|
+
## child_assocs - use child_assocs? - (direct) member/child assocs instead of member?
|
9
|
+
has_many :member_assoc_assocs, class_name: 'AssocAssoc', foreign_key: 'assoc1_id'
|
10
|
+
|
11
|
+
|
12
|
+
## note: split member_assocs into two sets (into national=true and national=false)
|
13
|
+
# e.g. fifa has six member confederations (non-national) and 216 national assocs
|
14
|
+
## note: includes all member (sub assocs + national assocs) - rename to member_assocs?
|
15
|
+
has_many :all_assocs, class_name: 'Assoc', :source => :assoc2, :through => :member_assoc_assocs
|
16
|
+
## use zone/region as name instead of sub ( for confederatons,zones,etc.)
|
17
|
+
has_many :sub_assocs, -> { where( national: false ) }, class_name: 'Assoc', :source => :assoc2, :through => :member_assoc_assocs
|
18
|
+
has_many :national_assocs, -> { where( national: true ) }, class_name: 'Assoc', :source => :assoc2, :through => :member_assoc_assocs
|
19
|
+
|
20
|
+
## for now can have more than one (direct) parent assoc
|
21
|
+
## e.g. Africa Fed and Arab League Fed
|
22
|
+
has_many :parent_assocs, class_name: 'Assoc', :source => :assoc1, :through => :parent_assoc_assocs
|
23
|
+
|
24
|
+
# assoc only can have one direct team for now (uses belongs_to on other side)
|
25
|
+
# has_one :team
|
26
|
+
end # class Assoc
|
27
|
+
|
28
|
+
|
29
|
+
class AssocAssoc < ActiveRecord::Base
|
30
|
+
self.table_name = 'assocs_assocs'
|
31
|
+
|
32
|
+
belongs_to :assoc1, class_name: 'Assoc', foreign_key: 'assoc1_id' # parent assoc
|
33
|
+
belongs_to :assoc2, class_name: 'Assoc', foreign_key: 'assoc2_id' # child assoc is_member_of parent assoc
|
34
|
+
|
35
|
+
end # class AssocAssoc
|
36
|
+
|
37
|
+
end # module Model
|
38
|
+
end # module SportDb
|
@@ -1,14 +1,14 @@
|
|
1
|
-
module SportDb
|
2
|
-
module Model
|
3
|
-
|
4
|
-
class Badge < ActiveRecord::Base
|
5
|
-
|
6
|
-
belongs_to :team
|
7
|
-
belongs_to :league
|
8
|
-
belongs_to :season
|
9
|
-
|
10
|
-
end # class Badge
|
11
|
-
|
12
|
-
|
13
|
-
end # module Model
|
14
|
-
end # module SportDb
|
1
|
+
module SportDb
|
2
|
+
module Model
|
3
|
+
|
4
|
+
class Badge < ActiveRecord::Base
|
5
|
+
|
6
|
+
belongs_to :team
|
7
|
+
belongs_to :league
|
8
|
+
belongs_to :season
|
9
|
+
|
10
|
+
end # class Badge
|
11
|
+
|
12
|
+
|
13
|
+
end # module Model
|
14
|
+
end # module SportDb
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module SportDb
|
4
|
+
module Model
|
5
|
+
|
6
|
+
class Event < ActiveRecord::Base
|
7
|
+
|
8
|
+
belongs_to :league
|
9
|
+
belongs_to :season
|
10
|
+
|
11
|
+
has_many :matches, -> { order('pos') }, class_name: 'Match'
|
12
|
+
|
13
|
+
has_many :rounds, -> { order('pos') }
|
14
|
+
has_many :groups, -> { order('pos') }
|
15
|
+
has_many :stages
|
16
|
+
|
17
|
+
has_many :event_teams, class_name: 'EventTeam'
|
18
|
+
has_many :teams, :through => :event_teams
|
19
|
+
|
20
|
+
has_many :event_grounds, class_name: 'EventGround'
|
21
|
+
has_many :grounds, :through => :event_grounds
|
22
|
+
|
23
|
+
|
24
|
+
before_save :on_before_save
|
25
|
+
|
26
|
+
def on_before_save
|
27
|
+
# event key is composite of league + season (e.g. at.2012/13) etc.
|
28
|
+
self.key = "#{league.key}.#{season.key}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def name
|
32
|
+
## todo/fix: check attr_reader(:name) or such first if NOT nil !!
|
33
|
+
"#{league.name} #{season.name}"
|
34
|
+
end
|
35
|
+
|
36
|
+
end # class Event
|
37
|
+
|
38
|
+
|
39
|
+
class EventTeam < ActiveRecord::Base
|
40
|
+
self.table_name = 'events_teams'
|
41
|
+
|
42
|
+
belongs_to :event
|
43
|
+
belongs_to :team
|
44
|
+
end # class EventTeam
|
45
|
+
|
46
|
+
|
47
|
+
class EventGround < ActiveRecord::Base
|
48
|
+
self.table_name = 'events_grounds'
|
49
|
+
|
50
|
+
belongs_to :event
|
51
|
+
belongs_to :ground
|
52
|
+
end # class EventGround
|
53
|
+
|
54
|
+
end # module Model
|
55
|
+
end # module SportDb
|
@@ -1,55 +1,55 @@
|
|
1
|
-
|
2
|
-
### forward references
|
3
|
-
## require first to resolve circular references
|
4
|
-
|
5
|
-
module SportDb
|
6
|
-
module Model
|
7
|
-
|
8
|
-
Prop = ConfDb::Model::Prop
|
9
|
-
|
10
|
-
## todo: why? why not use include WorldDb::Models here???
|
11
|
-
Continent = WorldDb::Model::Continent
|
12
|
-
Country = WorldDb::Model::Country
|
13
|
-
State = WorldDb::Model::State
|
14
|
-
City = WorldDb::Model::City
|
15
|
-
|
16
|
-
Person = PersonDb::Model::Person
|
17
|
-
|
18
|
-
##
|
19
|
-
# e.g. with belongs_to assoc (country,region)
|
20
|
-
|
21
|
-
class Assoc < ActiveRecord::Base ; end
|
22
|
-
class Team
|
23
|
-
class League < ActiveRecord::Base ; end
|
24
|
-
class Ground < ActiveRecord::Base ; end
|
25
|
-
class Goal
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
## add backwards compatible n convenience namespace
|
30
|
-
Models = Model
|
31
|
-
end # module SportDb
|
32
|
-
|
33
|
-
|
34
|
-
module WorldDb
|
35
|
-
module Model
|
36
|
-
|
37
|
-
# add alias? why? why not? # is there a better way?
|
38
|
-
# - just include SportDb::Models - why? why not?
|
39
|
-
# - just include once in loader??
|
40
|
-
Assoc = SportDb::Model::Assoc
|
41
|
-
Team = SportDb::Model::Team
|
42
|
-
League = SportDb::Model::League
|
43
|
-
Ground = SportDb::Model::Ground
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
module PersonDb
|
50
|
-
module Model
|
51
|
-
Goal = SportDb::Model::Goal
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
|
1
|
+
|
2
|
+
### forward references
|
3
|
+
## require first to resolve circular references
|
4
|
+
|
5
|
+
module SportDb
|
6
|
+
module Model
|
7
|
+
|
8
|
+
Prop = ConfDb::Model::Prop
|
9
|
+
|
10
|
+
## todo: why? why not use include WorldDb::Models here???
|
11
|
+
Continent = WorldDb::Model::Continent
|
12
|
+
Country = WorldDb::Model::Country
|
13
|
+
State = WorldDb::Model::State
|
14
|
+
City = WorldDb::Model::City
|
15
|
+
|
16
|
+
Person = PersonDb::Model::Person
|
17
|
+
|
18
|
+
## note: for now only team and league use worlddb tables
|
19
|
+
# e.g. with belongs_to assoc (country,region)
|
20
|
+
|
21
|
+
class Assoc < ActiveRecord::Base ; end
|
22
|
+
class Team < ActiveRecord::Base ; end
|
23
|
+
class League < ActiveRecord::Base ; end
|
24
|
+
class Ground < ActiveRecord::Base ; end
|
25
|
+
class Goal < ActiveRecord::Base ; end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
## add backwards compatible n convenience namespace
|
30
|
+
Models = Model
|
31
|
+
end # module SportDb
|
32
|
+
|
33
|
+
|
34
|
+
module WorldDb
|
35
|
+
module Model
|
36
|
+
|
37
|
+
# add alias? why? why not? # is there a better way?
|
38
|
+
# - just include SportDb::Models - why? why not?
|
39
|
+
# - just include once in loader??
|
40
|
+
Assoc = SportDb::Model::Assoc
|
41
|
+
Team = SportDb::Model::Team
|
42
|
+
League = SportDb::Model::League
|
43
|
+
Ground = SportDb::Model::Ground
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
module PersonDb
|
50
|
+
module Model
|
51
|
+
Goal = SportDb::Model::Goal
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
@@ -1,15 +1,15 @@
|
|
1
|
-
|
2
|
-
module SportDb
|
3
|
-
module Model
|
4
|
-
|
5
|
-
|
6
|
-
class Goal < ActiveRecord::Base
|
7
|
-
|
8
|
-
belongs_to :
|
9
|
-
belongs_to :person, class_name: 'PersonDb::Model::Person', foreign_key: 'person_id'
|
10
|
-
|
11
|
-
end # class Goal
|
12
|
-
|
13
|
-
|
14
|
-
end # module Model
|
15
|
-
end # module SportDb
|
1
|
+
|
2
|
+
module SportDb
|
3
|
+
module Model
|
4
|
+
|
5
|
+
|
6
|
+
class Goal < ActiveRecord::Base
|
7
|
+
|
8
|
+
belongs_to :match
|
9
|
+
belongs_to :person, class_name: 'PersonDb::Model::Person', foreign_key: 'person_id'
|
10
|
+
|
11
|
+
end # class Goal
|
12
|
+
|
13
|
+
|
14
|
+
end # module Model
|
15
|
+
end # module SportDb
|
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
module SportDb
|
3
|
+
module Model
|
4
|
+
|
5
|
+
class Ground < ActiveRecord::Base
|
6
|
+
|
7
|
+
belongs_to :country, class_name: 'WorldDb::Model::Country', foreign_key: 'country_id'
|
8
|
+
belongs_to :city, class_name: 'WorldDb::Model::City', foreign_key: 'city_id'
|
9
|
+
|
10
|
+
has_many :matches
|
11
|
+
|
12
|
+
end # class Ground
|
13
|
+
|
14
|
+
end # module Model
|
15
|
+
end # module SportDb
|
16
|
+
|
@@ -5,11 +5,7 @@ module SportDb
|
|
5
5
|
|
6
6
|
class Group < ActiveRecord::Base
|
7
7
|
|
8
|
-
|
9
|
-
has_many :games, order: 'pos'
|
10
|
-
else
|
11
|
-
has_many :games, -> { order('pos') }
|
12
|
-
end
|
8
|
+
has_many :matches, -> { order('pos') }, class_name: 'Match'
|
13
9
|
|
14
10
|
belongs_to :event
|
15
11
|
|
@@ -17,7 +13,14 @@ end
|
|
17
13
|
has_many :teams, :through => :group_teams
|
18
14
|
|
19
15
|
end # class Group
|
20
|
-
|
21
|
-
|
16
|
+
|
17
|
+
|
18
|
+
class GroupTeam < ActiveRecord::Base
|
19
|
+
self.table_name = 'groups_teams'
|
20
|
+
|
21
|
+
belongs_to :group
|
22
|
+
belongs_to :team
|
23
|
+
end # class GroupTeam
|
24
|
+
|
22
25
|
end # module Model
|
23
26
|
end # module SportDb
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module SportDb
|
2
|
+
module Model
|
3
|
+
|
4
|
+
|
5
|
+
class League < ActiveRecord::Base
|
6
|
+
|
7
|
+
## leagues also used for conferences, world series, cups, etc.
|
8
|
+
#
|
9
|
+
## league (or cup/conference/series/etc.) + season (or year) = event
|
10
|
+
|
11
|
+
has_many :events
|
12
|
+
has_many :seasons, :through => :events
|
13
|
+
|
14
|
+
belongs_to :country, :class_name => 'WorldDb::Model::Country', :foreign_key => 'country_id'
|
15
|
+
|
16
|
+
end # class League
|
17
|
+
|
18
|
+
|
19
|
+
end # module Model
|
20
|
+
end # module SportDb
|
@@ -1,18 +1,17 @@
|
|
1
|
-
|
2
|
-
module SportDb
|
3
|
-
module Model
|
4
|
-
|
5
|
-
### use
|
6
|
-
|
7
|
-
class
|
8
|
-
|
9
|
-
belongs_to :event
|
10
|
-
belongs_to :team
|
11
|
-
belongs_to :person, class_name: 'PersonDb::Model::Person', foreign_key: 'person_id'
|
12
|
-
|
13
|
-
end # class
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
1
|
+
|
2
|
+
module SportDb
|
3
|
+
module Model
|
4
|
+
|
5
|
+
### use Squad for name? - alias??
|
6
|
+
|
7
|
+
class Lineup < ActiveRecord::Base
|
8
|
+
|
9
|
+
belongs_to :event
|
10
|
+
belongs_to :team
|
11
|
+
belongs_to :person, class_name: 'PersonDb::Model::Person', foreign_key: 'person_id'
|
12
|
+
|
13
|
+
end # class Lineup
|
14
|
+
|
15
|
+
end # module Model
|
16
|
+
end # module SportDb
|
17
|
+
|
@@ -3,14 +3,18 @@ module SportDb
|
|
3
3
|
module Model
|
4
4
|
|
5
5
|
|
6
|
-
class
|
6
|
+
class Match < ActiveRecord::Base
|
7
|
+
|
8
|
+
self.table_name = 'matches'
|
7
9
|
|
8
10
|
belongs_to :team1, class_name: 'Team', foreign_key: 'team1_id'
|
9
11
|
belongs_to :team2, class_name: 'Team', foreign_key: 'team2_id'
|
10
|
-
|
11
|
-
belongs_to :
|
12
|
+
|
13
|
+
belongs_to :event
|
14
|
+
belongs_to :round # round is optional
|
12
15
|
belongs_to :group # group is optional
|
13
|
-
|
16
|
+
belongs_to :stage # stage is optional
|
17
|
+
|
14
18
|
belongs_to :ground # ground is optional
|
15
19
|
belongs_to :city, class_name: 'WorldDb::Model::City', foreign_key: 'city_id' # city is optioanl (remove?? redundant?? use ground ??)
|
16
20
|
|
@@ -27,7 +31,7 @@ class Game < ActiveRecord::Base
|
|
27
31
|
def toto12x() toto1x2; end # alias for toto12x - todo/fix: use ruby alias helper
|
28
32
|
def toto1x2
|
29
33
|
## note: will return string e.g. 1-X-2 (winner will return int e.g. 1-0-2)
|
30
|
-
|
34
|
+
|
31
35
|
## fix: use switch/when expr/stmt instead of ifs
|
32
36
|
value = winner90 # 1 0 2 1 => team 1 0 => draw 2 => team
|
33
37
|
if value == 0
|
@@ -82,11 +86,11 @@ class Game < ActiveRecord::Base
|
|
82
86
|
end
|
83
87
|
|
84
88
|
## todo/fix:
|
85
|
-
# check for next-
|
89
|
+
# check for next-match/pre-match !!!
|
86
90
|
# use 1st leg and 2nd leg - use for winner too
|
87
91
|
# or add new winner_total or winner_aggregated method ???
|
88
92
|
|
89
|
-
## check for penalty - note: some
|
93
|
+
## check for penalty - note: some matches might only have penalty and no extra time (e.g. copa liberatadores)
|
90
94
|
if score1p.present? && score2p.present?
|
91
95
|
if score1p > score2p
|
92
96
|
self.winner = 1
|
@@ -114,7 +118,7 @@ class Game < ActiveRecord::Base
|
|
114
118
|
|
115
119
|
|
116
120
|
### getter/setters for deprecated attribs (score3,4,5,6) n national
|
117
|
-
|
121
|
+
|
118
122
|
def score1ot() score1et end
|
119
123
|
def score2ot() score2et end
|
120
124
|
|
@@ -122,61 +126,15 @@ class Game < ActiveRecord::Base
|
|
122
126
|
def score2ot=(value) self.score2et = value end
|
123
127
|
|
124
128
|
|
125
|
-
#
|
126
|
-
|
129
|
+
# match over?
|
130
|
+
## todo/fix: add back time (hours/minutes) to date if present!!!!
|
131
|
+
def over?() date <= Date.today; end
|
127
132
|
|
128
133
|
## fix/todo: already added by ar magic ??? remove code
|
129
134
|
def knockout?() knockout == true; end
|
130
135
|
def complete?() score1.present? && score2.present?; end
|
131
136
|
|
132
137
|
|
133
|
-
############# convenience helpers for styling
|
134
|
-
##
|
135
|
-
|
136
|
-
def team1_style_class
|
137
|
-
buf = ''
|
138
|
-
## NB: remove if calc?
|
139
|
-
|
140
|
-
### fix: loser
|
141
|
-
## - add method for checking winner/loser on ko pairs using (1st leg/2nd leg totals) ??
|
142
|
-
## use new winner_total method ??
|
143
|
-
|
144
|
-
if complete?
|
145
|
-
if winner1?
|
146
|
-
buf << 'game-team-winner '
|
147
|
-
elsif winner2?
|
148
|
-
buf << 'game-team-loser '
|
149
|
-
else # assume draw
|
150
|
-
buf << 'game-team-draw '
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
buf << 'game-knockout ' if knockout?
|
155
|
-
buf
|
156
|
-
end
|
157
|
-
|
158
|
-
def team2_style_class
|
159
|
-
buf = ''
|
160
|
-
## NB: remove if calc?
|
161
|
-
|
162
|
-
### fix: loser
|
163
|
-
## - add method for checking winner/loser on ko pairs using (1st leg/2nd leg totals) ??
|
164
|
-
## use new winner_total method ??
|
165
|
-
|
166
|
-
if complete?
|
167
|
-
if winner1?
|
168
|
-
buf << 'game-team-loser '
|
169
|
-
elsif winner2?
|
170
|
-
buf << 'game-team-winner '
|
171
|
-
else # assume draw
|
172
|
-
buf << 'game-team-draw '
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
buf << 'game-knockout ' if knockout?
|
177
|
-
buf
|
178
|
-
end
|
179
|
-
|
180
138
|
|
181
139
|
def play_at_str( format = nil )
|
182
140
|
## e.g. use like
|
@@ -218,7 +176,7 @@ class Game < ActiveRecord::Base
|
|
218
176
|
|
219
177
|
## todo/fix: find a better name?
|
220
178
|
## todo: move to utils for reuse?
|
221
|
-
|
179
|
+
|
222
180
|
def check_for_changes( new_attributes )
|
223
181
|
changes_counter = 0
|
224
182
|
new_attributes.each do |key,new_value|
|
@@ -231,14 +189,13 @@ class Game < ActiveRecord::Base
|
|
231
189
|
puts "change #{changes_counter} for #{key} old:>#{old_value}< : #{old_value.class.name} new:>#{new_value}< : #{new_value.class.name}"
|
232
190
|
end
|
233
191
|
end
|
234
|
-
|
192
|
+
|
235
193
|
# no changes found for counter==0;
|
236
194
|
# -- otherwise x changes found; return true
|
237
195
|
changes_counter == 0 ? false : true
|
238
196
|
end
|
239
197
|
|
240
|
-
end # class
|
241
|
-
|
198
|
+
end # class Match
|
242
199
|
|
243
200
|
end # module Model
|
244
201
|
end # module SportDb
|