sportdb-models 1.18.5 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +27 -145
- data/Rakefile +4 -5
- data/lib/sportdb/models.rb +93 -160
- data/lib/sportdb/{deleter.rb → models/deleter.rb} +4 -10
- 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} +1 -1
- data/lib/sportdb/models/models/event.rb +55 -0
- data/lib/sportdb/models/{forward.rb → models/forward.rb} +3 -3
- data/lib/sportdb/models/{goal.rb → models/goal.rb} +1 -1
- 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} +3 -4
- data/lib/sportdb/models/{game.rb → models/match.rb} +18 -61
- data/lib/sportdb/models/{person.rb → models/person.rb} +0 -0
- data/lib/sportdb/models/{round.rb → models/round.rb} +1 -6
- data/lib/sportdb/models/{season.rb → models/season.rb} +2 -1
- 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} +11 -1
- 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 +0 -0
- data/lib/sportdb/models/{world → models/world}/country.rb +0 -0
- data/lib/sportdb/models/{world → models/world}/state.rb +0 -0
- data/lib/sportdb/{schema.rb → models/schema.rb} +165 -100
- data/lib/sportdb/models/stats.rb +23 -0
- data/lib/sportdb/models/utils.rb +24 -24
- data/lib/sportdb/{version.rb → models/version.rb} +12 -5
- data/test/helper.rb +10 -114
- data/test/test_changes.rb +38 -38
- data/test/test_cursor.rb +15 -15
- data/test/test_winner.rb +75 -70
- metadata +29 -161
- data/lib/sportdb/calc.rb +0 -279
- data/lib/sportdb/indexers/team.rb +0 -87
- data/lib/sportdb/mapper_teams.rb +0 -24
- data/lib/sportdb/matcher.rb +0 -31
- 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/pretty_printer.rb +0 -175
- data/lib/sportdb/reader.rb +0 -132
- data/lib/sportdb/reader_file.rb +0 -131
- data/lib/sportdb/reader_zip.rb +0 -172
- data/lib/sportdb/readers/assoc.rb +0 -54
- data/lib/sportdb/readers/event.rb +0 -253
- data/lib/sportdb/readers/event_meta.rb +0 -133
- data/lib/sportdb/readers/event_table.rb +0 -196
- data/lib/sportdb/readers/game.rb +0 -912
- data/lib/sportdb/readers/ground.rb +0 -53
- data/lib/sportdb/readers/league.rb +0 -54
- data/lib/sportdb/readers/season.rb +0 -83
- data/lib/sportdb/readers/squad_club.rb +0 -201
- data/lib/sportdb/readers/squad_national_team.rb +0 -173
- data/lib/sportdb/readers/team.rb +0 -53
- data/lib/sportdb/rsssf_reader.rb +0 -367
- data/lib/sportdb/standings.rb +0 -178
- data/lib/sportdb/stats.rb +0 -27
- data/lib/sportdb/utils.rb +0 -89
- data/lib/sportdb/utils_date.rb +0 -26
- data/lib/sportdb/utils_goals.rb +0 -20
- data/lib/sportdb/utils_group.rb +0 -63
- data/lib/sportdb/utils_map.rb +0 -44
- data/lib/sportdb/utils_round.rb +0 -165
- data/lib/sportdb/utils_scores.rb +0 -17
- data/lib/sportdb/utils_teams.rb +0 -48
- data/test/data/at-austria/2013_14/bl.txt +0 -227
- data/test/data/at-austria/2013_14/bl.yml +0 -30
- data/test/data/at-austria/2013_14/bl_ii.txt +0 -154
- data/test/data/at-austria/2013_14/el.txt +0 -4
- data/test/data/at-austria/2013_14/el.yml +0 -25
- data/test/data/at-austria/2013_14/squads/austria.txt +0 -40
- data/test/data/at-austria/2013_14/squads/salzburg.txt +0 -35
- data/test/data/at-austria/2014_15/1-bundesliga-ii.txt +0 -158
- data/test/data/at-austria/2014_15/1-bundesliga.yml +0 -18
- data/test/data/at-austria/2015_16/1-bundesliga-v2.conf.txt +0 -20
- data/test/data/at-austria/2015_16/1-bundesliga-v2.yml +0 -20
- data/test/data/at-austria/2015_16/1-bundesliga.conf.txt +0 -20
- data/test/data/at-austria/2015_16/1-bundesliga.yml +0 -24
- data/test/data/at-austria/2015_16/cup.yml +0 -77
- data/test/data/at-austria/leagues.txt +0 -11
- data/test/data/at-austria/teams.txt +0 -68
- data/test/data/at-austria/teams_2.txt +0 -21
- data/test/data/csv/de-2013-14--1-bundesliga.txt +0 -307
- data/test/data/de-deutschland/2013-14/1-bundesliga.yml +0 -26
- data/test/data/de-deutschland/leagues.txt +0 -4
- data/test/data/de-deutschland/teams.txt +0 -53
- data/test/data/eng-england/2015-16/1-premierleague-v2.yml +0 -2
- data/test/data/eng-england/2015-16/1-premierleague.yml +0 -5
- data/test/data/national-teams/assocs.txt +0 -231
- data/test/data/national-teams/europe/assocs.txt +0 -13
- data/test/data/national-teams/europe/teams.txt +0 -13
- data/test/data/national-teams/north-america/assocs.txt +0 -10
- data/test/data/national-teams/north-america/teams.txt +0 -7
- data/test/data/national-teams/teams.txt +0 -19
- data/test/data/players/europe/at-austria/players.txt +0 -45
- data/test/data/players/europe/de-deutschland/players.txt +0 -41
- data/test/data/players/south-america/br-brazil/players.txt +0 -51
- data/test/data/rsssf/at-2014-15--1-bundesliga.txt +0 -339
- data/test/data/rsssf/at-2015-16--1-bundesliga.txt +0 -18
- data/test/data/world-cup/1930/cup.txt +0 -71
- data/test/data/world-cup/1930/cup.yml +0 -23
- data/test/data/world-cup/1930/cup_goals.txt +0 -47
- data/test/data/world-cup/1930/cup_goals.yml +0 -23
- data/test/data/world-cup/1954/cup.txt +0 -90
- data/test/data/world-cup/1954/cup.yml +0 -30
- data/test/data/world-cup/1962/cup.txt +0 -86
- data/test/data/world-cup/1962/cup.yml +0 -32
- data/test/data/world-cup/1974/cup.yml +0 -35
- data/test/data/world-cup/1974/cup_finals.txt +0 -14
- data/test/data/world-cup/1974/cup_i.txt +0 -55
- data/test/data/world-cup/1974/cup_ii.txt +0 -34
- data/test/data/world-cup/2014/cup.txt +0 -5
- data/test/data/world-cup/2014/cup.yml +0 -54
- data/test/data/world-cup/2014/squads/br-brazil.txt +0 -46
- data/test/data/world-cup/2014/squads/de-deutschland.txt +0 -8
- data/test/data/world-cup/2014/squads/jp-japan.txt +0 -30
- data/test/data/world-cup/2014/squads/uy-uruguay.txt +0 -32
- data/test/data/world-cup/leagues.txt +0 -5
- data/test/data/world-cup/seasons_1930.txt +0 -4
- data/test/data/world-cup/seasons_1954.txt +0 -4
- data/test/data/world-cup/seasons_1962.txt +0 -4
- data/test/data/world-cup/seasons_1974.txt +0 -5
- data/test/data/world-cup/teams_1930.txt +0 -26
- data/test/data/world-cup/teams_1954.txt +0 -30
- data/test/data/world-cup/teams_1962.txt +0 -29
- data/test/data/world-cup/teams_1974.txt +0 -29
- data/test/test_assoc_reader.rb +0 -199
- data/test/test_event_meta_reader.rb +0 -47
- data/test/test_event_reader.rb +0 -64
- data/test/test_event_table_reader.rb +0 -57
- data/test/test_goals.rb +0 -107
- data/test/test_indexer_team.rb +0 -34
- data/test/test_load.rb +0 -61
- data/test/test_pp.rb +0 -35
- data/test/test_reader.rb +0 -88
- data/test/test_reader_from_string.rb +0 -63
- data/test/test_round_auto.rb +0 -370
- data/test/test_round_def.rb +0 -109
- data/test/test_round_header.rb +0 -183
- data/test/test_rsssf_reader.rb +0 -76
- data/test/test_squad_club_reader.rb +0 -76
- data/test/test_squad_national_team_reader.rb +0 -116
- data/test/test_standings.rb +0 -279
- data/test/test_standings_ii.rb +0 -46
- data/test/test_utils.rb +0 -124
data/test/test_winner.rb
CHANGED
@@ -1,95 +1,100 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_winner.rb
|
6
|
+
|
7
|
+
|
3
8
|
require 'helper'
|
4
9
|
|
5
10
|
class TestWinner < MiniTest::Test
|
6
11
|
|
7
12
|
def test_1_2
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
assert_equal 2,
|
14
|
-
assert_equal 2,
|
15
|
-
assert_equal true,
|
16
|
-
assert_equal false,
|
17
|
-
assert_equal false,
|
13
|
+
match = Match.new
|
14
|
+
match.score1 = 1
|
15
|
+
match.score2 = 2
|
16
|
+
match.calc_winner
|
17
|
+
|
18
|
+
assert_equal 2, match.winner90
|
19
|
+
assert_equal 2, match.winner
|
20
|
+
assert_equal true, match.winner2?
|
21
|
+
assert_equal false, match.winner1?
|
22
|
+
assert_equal false, match.draw?
|
18
23
|
end
|
19
24
|
|
20
25
|
def test_1_1
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
assert_equal 0,
|
27
|
-
assert_equal 0,
|
28
|
-
assert_equal true,
|
29
|
-
assert_equal false,
|
30
|
-
assert_equal false,
|
26
|
+
match = Match.new
|
27
|
+
match.score1 = 1
|
28
|
+
match.score2 = 1
|
29
|
+
match.calc_winner
|
30
|
+
|
31
|
+
assert_equal 0, match.winner90
|
32
|
+
assert_equal 0, match.winner
|
33
|
+
assert_equal true, match.draw?
|
34
|
+
assert_equal false, match.winner1?
|
35
|
+
assert_equal false, match.winner2?
|
31
36
|
end
|
32
37
|
|
33
38
|
def test_2_1
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
assert_equal 1,
|
40
|
-
assert_equal 1,
|
41
|
-
assert_equal true,
|
42
|
-
assert_equal false,
|
43
|
-
assert_equal false,
|
39
|
+
match = Match.new
|
40
|
+
match.score1 = 2
|
41
|
+
match.score2 = 1
|
42
|
+
match.calc_winner
|
43
|
+
|
44
|
+
assert_equal 1, match.winner90
|
45
|
+
assert_equal 1, match.winner
|
46
|
+
assert_equal true, match.winner1?
|
47
|
+
assert_equal false, match.winner2?
|
48
|
+
assert_equal false, match.draw?
|
44
49
|
end
|
45
50
|
|
46
51
|
def test_1_1__2_1
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
assert_equal 0,
|
55
|
-
assert_equal 1,
|
56
|
-
assert_equal true,
|
57
|
-
assert_equal false,
|
58
|
-
assert_equal false,
|
52
|
+
match = Match.new
|
53
|
+
match.score1 = 1
|
54
|
+
match.score2 = 1
|
55
|
+
match.score1et = 2
|
56
|
+
match.score2et = 1
|
57
|
+
match.calc_winner
|
58
|
+
|
59
|
+
assert_equal 0, match.winner90
|
60
|
+
assert_equal 1, match.winner
|
61
|
+
assert_equal true, match.winner1?
|
62
|
+
assert_equal false, match.winner2?
|
63
|
+
assert_equal false, match.draw?
|
59
64
|
end
|
60
65
|
|
61
66
|
def test_1_1__2_2__3_5
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
assert_equal 0,
|
72
|
-
assert_equal 2,
|
73
|
-
assert_equal true,
|
74
|
-
assert_equal false,
|
75
|
-
assert_equal false,
|
67
|
+
match = Match.new
|
68
|
+
match.score1 = 1
|
69
|
+
match.score2 = 1
|
70
|
+
match.score1et = 2
|
71
|
+
match.score2et = 2
|
72
|
+
match.score1p = 3
|
73
|
+
match.score2p = 5
|
74
|
+
match.calc_winner
|
75
|
+
|
76
|
+
assert_equal 0, match.winner90
|
77
|
+
assert_equal 2, match.winner
|
78
|
+
assert_equal true, match.winner2?
|
79
|
+
assert_equal false, match.winner1?
|
80
|
+
assert_equal false, match.draw?
|
76
81
|
end
|
77
82
|
|
78
83
|
def test_1_1_x_3_5
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
assert_equal 0,
|
89
|
-
assert_equal 2,
|
90
|
-
assert_equal true,
|
91
|
-
assert_equal false,
|
92
|
-
assert_equal false,
|
84
|
+
match = Match.new
|
85
|
+
match.score1 = 1
|
86
|
+
match.score2 = 1
|
87
|
+
match.score1et = nil
|
88
|
+
match.score2et = nil
|
89
|
+
match.score1p = 3
|
90
|
+
match.score2p = 5
|
91
|
+
match.calc_winner
|
92
|
+
|
93
|
+
assert_equal 0, match.winner90
|
94
|
+
assert_equal 2, match.winner
|
95
|
+
assert_equal true, match.winner2?
|
96
|
+
assert_equal false, match.winner1?
|
97
|
+
assert_equal false, match.draw?
|
93
98
|
end
|
94
99
|
|
95
100
|
end # class TestWinner
|
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:
|
4
|
+
version: 2.0.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:
|
11
|
+
date: 2020-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: worlddb-models
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.5.0
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: sportdb-formats
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 0.1.2
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 0.1.2
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: rdoc
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -93,156 +79,38 @@ files:
|
|
93
79
|
- Manifest.txt
|
94
80
|
- README.md
|
95
81
|
- Rakefile
|
96
|
-
- lib/sportdb/calc.rb
|
97
|
-
- lib/sportdb/deleter.rb
|
98
|
-
- lib/sportdb/indexers/team.rb
|
99
|
-
- lib/sportdb/mapper_teams.rb
|
100
|
-
- lib/sportdb/matcher.rb
|
101
82
|
- lib/sportdb/models.rb
|
102
|
-
- lib/sportdb/models/
|
103
|
-
- lib/sportdb/models/
|
104
|
-
- lib/sportdb/models/
|
105
|
-
- lib/sportdb/models/
|
106
|
-
- lib/sportdb/models/
|
107
|
-
- lib/sportdb/models/
|
108
|
-
- lib/sportdb/models/
|
109
|
-
- lib/sportdb/models/
|
110
|
-
- lib/sportdb/models/
|
111
|
-
- lib/sportdb/models/
|
112
|
-
- lib/sportdb/models/
|
113
|
-
- lib/sportdb/models/
|
114
|
-
- lib/sportdb/models/
|
115
|
-
- lib/sportdb/models/
|
116
|
-
- lib/sportdb/models/
|
117
|
-
- lib/sportdb/models/
|
118
|
-
- lib/sportdb/models/
|
119
|
-
- lib/sportdb/models/
|
120
|
-
- lib/sportdb/models/
|
121
|
-
- lib/sportdb/models/
|
122
|
-
- lib/sportdb/models/
|
123
|
-
- lib/sportdb/models/
|
124
|
-
- lib/sportdb/models/
|
125
|
-
- lib/sportdb/models/
|
126
|
-
- lib/sportdb/models/
|
127
|
-
- lib/sportdb/models/
|
128
|
-
- lib/sportdb/models/team_compat.rb
|
83
|
+
- lib/sportdb/models/deleter.rb
|
84
|
+
- lib/sportdb/models/formats.rb
|
85
|
+
- lib/sportdb/models/models/assoc.rb
|
86
|
+
- lib/sportdb/models/models/badge.rb
|
87
|
+
- lib/sportdb/models/models/event.rb
|
88
|
+
- lib/sportdb/models/models/forward.rb
|
89
|
+
- lib/sportdb/models/models/goal.rb
|
90
|
+
- lib/sportdb/models/models/ground.rb
|
91
|
+
- lib/sportdb/models/models/group.rb
|
92
|
+
- lib/sportdb/models/models/league.rb
|
93
|
+
- lib/sportdb/models/models/lineup.rb
|
94
|
+
- lib/sportdb/models/models/match.rb
|
95
|
+
- lib/sportdb/models/models/person.rb
|
96
|
+
- lib/sportdb/models/models/round.rb
|
97
|
+
- lib/sportdb/models/models/season.rb
|
98
|
+
- lib/sportdb/models/models/stage.rb
|
99
|
+
- lib/sportdb/models/models/stats/alltime_standing.rb
|
100
|
+
- lib/sportdb/models/models/stats/event_standing.rb
|
101
|
+
- lib/sportdb/models/models/stats/group_standing.rb
|
102
|
+
- lib/sportdb/models/models/team.rb
|
103
|
+
- lib/sportdb/models/models/world/city.rb
|
104
|
+
- lib/sportdb/models/models/world/continent.rb
|
105
|
+
- lib/sportdb/models/models/world/country.rb
|
106
|
+
- lib/sportdb/models/models/world/state.rb
|
107
|
+
- lib/sportdb/models/schema.rb
|
108
|
+
- lib/sportdb/models/stats.rb
|
129
109
|
- lib/sportdb/models/utils.rb
|
130
|
-
- lib/sportdb/models/
|
131
|
-
- lib/sportdb/models/world/continent.rb
|
132
|
-
- lib/sportdb/models/world/country.rb
|
133
|
-
- lib/sportdb/models/world/state.rb
|
134
|
-
- lib/sportdb/patterns.rb
|
135
|
-
- lib/sportdb/pretty_printer.rb
|
136
|
-
- lib/sportdb/reader.rb
|
137
|
-
- lib/sportdb/reader_file.rb
|
138
|
-
- lib/sportdb/reader_zip.rb
|
139
|
-
- lib/sportdb/readers/assoc.rb
|
140
|
-
- lib/sportdb/readers/event.rb
|
141
|
-
- lib/sportdb/readers/event_meta.rb
|
142
|
-
- lib/sportdb/readers/event_table.rb
|
143
|
-
- lib/sportdb/readers/game.rb
|
144
|
-
- lib/sportdb/readers/ground.rb
|
145
|
-
- lib/sportdb/readers/league.rb
|
146
|
-
- lib/sportdb/readers/season.rb
|
147
|
-
- lib/sportdb/readers/squad_club.rb
|
148
|
-
- lib/sportdb/readers/squad_national_team.rb
|
149
|
-
- lib/sportdb/readers/team.rb
|
150
|
-
- lib/sportdb/rsssf_reader.rb
|
151
|
-
- lib/sportdb/schema.rb
|
152
|
-
- lib/sportdb/standings.rb
|
153
|
-
- lib/sportdb/stats.rb
|
154
|
-
- lib/sportdb/utils.rb
|
155
|
-
- lib/sportdb/utils_date.rb
|
156
|
-
- lib/sportdb/utils_goals.rb
|
157
|
-
- lib/sportdb/utils_group.rb
|
158
|
-
- lib/sportdb/utils_map.rb
|
159
|
-
- lib/sportdb/utils_round.rb
|
160
|
-
- lib/sportdb/utils_scores.rb
|
161
|
-
- lib/sportdb/utils_teams.rb
|
162
|
-
- lib/sportdb/version.rb
|
163
|
-
- test/data/at-austria/2013_14/bl.txt
|
164
|
-
- test/data/at-austria/2013_14/bl.yml
|
165
|
-
- test/data/at-austria/2013_14/bl_ii.txt
|
166
|
-
- test/data/at-austria/2013_14/el.txt
|
167
|
-
- test/data/at-austria/2013_14/el.yml
|
168
|
-
- test/data/at-austria/2013_14/squads/austria.txt
|
169
|
-
- test/data/at-austria/2013_14/squads/salzburg.txt
|
170
|
-
- test/data/at-austria/2014_15/1-bundesliga-ii.txt
|
171
|
-
- test/data/at-austria/2014_15/1-bundesliga.yml
|
172
|
-
- test/data/at-austria/2015_16/1-bundesliga-v2.conf.txt
|
173
|
-
- test/data/at-austria/2015_16/1-bundesliga-v2.yml
|
174
|
-
- test/data/at-austria/2015_16/1-bundesliga.conf.txt
|
175
|
-
- test/data/at-austria/2015_16/1-bundesliga.yml
|
176
|
-
- test/data/at-austria/2015_16/cup.yml
|
177
|
-
- test/data/at-austria/leagues.txt
|
178
|
-
- test/data/at-austria/teams.txt
|
179
|
-
- test/data/at-austria/teams_2.txt
|
180
|
-
- test/data/csv/de-2013-14--1-bundesliga.txt
|
181
|
-
- test/data/de-deutschland/2013-14/1-bundesliga.yml
|
182
|
-
- test/data/de-deutschland/leagues.txt
|
183
|
-
- test/data/de-deutschland/teams.txt
|
184
|
-
- test/data/eng-england/2015-16/1-premierleague-v2.yml
|
185
|
-
- test/data/eng-england/2015-16/1-premierleague.yml
|
186
|
-
- test/data/national-teams/assocs.txt
|
187
|
-
- test/data/national-teams/europe/assocs.txt
|
188
|
-
- test/data/national-teams/europe/teams.txt
|
189
|
-
- test/data/national-teams/north-america/assocs.txt
|
190
|
-
- test/data/national-teams/north-america/teams.txt
|
191
|
-
- test/data/national-teams/teams.txt
|
192
|
-
- test/data/players/europe/at-austria/players.txt
|
193
|
-
- test/data/players/europe/de-deutschland/players.txt
|
194
|
-
- test/data/players/south-america/br-brazil/players.txt
|
195
|
-
- test/data/rsssf/at-2014-15--1-bundesliga.txt
|
196
|
-
- test/data/rsssf/at-2015-16--1-bundesliga.txt
|
197
|
-
- test/data/world-cup/1930/cup.txt
|
198
|
-
- test/data/world-cup/1930/cup.yml
|
199
|
-
- test/data/world-cup/1930/cup_goals.txt
|
200
|
-
- test/data/world-cup/1930/cup_goals.yml
|
201
|
-
- test/data/world-cup/1954/cup.txt
|
202
|
-
- test/data/world-cup/1954/cup.yml
|
203
|
-
- test/data/world-cup/1962/cup.txt
|
204
|
-
- test/data/world-cup/1962/cup.yml
|
205
|
-
- test/data/world-cup/1974/cup.yml
|
206
|
-
- test/data/world-cup/1974/cup_finals.txt
|
207
|
-
- test/data/world-cup/1974/cup_i.txt
|
208
|
-
- test/data/world-cup/1974/cup_ii.txt
|
209
|
-
- test/data/world-cup/2014/cup.txt
|
210
|
-
- test/data/world-cup/2014/cup.yml
|
211
|
-
- test/data/world-cup/2014/squads/br-brazil.txt
|
212
|
-
- test/data/world-cup/2014/squads/de-deutschland.txt
|
213
|
-
- test/data/world-cup/2014/squads/jp-japan.txt
|
214
|
-
- test/data/world-cup/2014/squads/uy-uruguay.txt
|
215
|
-
- test/data/world-cup/leagues.txt
|
216
|
-
- test/data/world-cup/seasons_1930.txt
|
217
|
-
- test/data/world-cup/seasons_1954.txt
|
218
|
-
- test/data/world-cup/seasons_1962.txt
|
219
|
-
- test/data/world-cup/seasons_1974.txt
|
220
|
-
- test/data/world-cup/teams_1930.txt
|
221
|
-
- test/data/world-cup/teams_1954.txt
|
222
|
-
- test/data/world-cup/teams_1962.txt
|
223
|
-
- test/data/world-cup/teams_1974.txt
|
110
|
+
- lib/sportdb/models/version.rb
|
224
111
|
- test/helper.rb
|
225
|
-
- test/test_assoc_reader.rb
|
226
112
|
- test/test_changes.rb
|
227
113
|
- test/test_cursor.rb
|
228
|
-
- test/test_event_meta_reader.rb
|
229
|
-
- test/test_event_reader.rb
|
230
|
-
- test/test_event_table_reader.rb
|
231
|
-
- test/test_goals.rb
|
232
|
-
- test/test_indexer_team.rb
|
233
|
-
- test/test_load.rb
|
234
|
-
- test/test_pp.rb
|
235
|
-
- test/test_reader.rb
|
236
|
-
- test/test_reader_from_string.rb
|
237
|
-
- test/test_round_auto.rb
|
238
|
-
- test/test_round_def.rb
|
239
|
-
- test/test_round_header.rb
|
240
|
-
- test/test_rsssf_reader.rb
|
241
|
-
- test/test_squad_club_reader.rb
|
242
|
-
- test/test_squad_national_team_reader.rb
|
243
|
-
- test/test_standings.rb
|
244
|
-
- test/test_standings_ii.rb
|
245
|
-
- test/test_utils.rb
|
246
114
|
- test/test_winner.rb
|
247
115
|
homepage: https://github.com/sportdb/sport.db
|
248
116
|
licenses:
|
data/lib/sportdb/calc.rb
DELETED
@@ -1,279 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module SportDb
|
4
|
-
|
5
|
-
############
|
6
|
-
##
|
7
|
-
## fix/todo: obsolete
|
8
|
-
## - use new Standings class
|
9
|
-
|
10
|
-
|
11
|
-
##############################################
|
12
|
-
# helper/ builds standings table in memory
|
13
|
-
# - find a better module name for StandingsHelper ?? why? why not?
|
14
|
-
|
15
|
-
|
16
|
-
module StandingsHelper
|
17
|
-
|
18
|
-
## todo:
|
19
|
-
## add team_id to struct - why? why not? - saves a db lookup?
|
20
|
-
class Stats
|
21
|
-
### fix/todo: change/rename :pos to :rank
|
22
|
-
attr_accessor :pos, :played, :won, :lost, :drawn,
|
23
|
-
:goals_for, :goals_against, :pts,
|
24
|
-
:recs
|
25
|
-
|
26
|
-
def initialize
|
27
|
-
@pos = nil # use 0? why? why not?
|
28
|
-
@played = 0
|
29
|
-
@won = 0
|
30
|
-
@lost = 0
|
31
|
-
@drawn = 0
|
32
|
-
@goals_for = 0
|
33
|
-
@goals_against = 0
|
34
|
-
@pts = 0
|
35
|
-
@recs = 0
|
36
|
-
# note: appearances (event) count or similar
|
37
|
-
# is recs counter (number of (stats) records)
|
38
|
-
end
|
39
|
-
|
40
|
-
def add( rec )
|
41
|
-
### fix: add plus + operator too!
|
42
|
-
|
43
|
-
# note: will NOT update/add pos (ranking)
|
44
|
-
self.played += rec.played
|
45
|
-
self.won += rec.won
|
46
|
-
self.lost += rec.lost
|
47
|
-
self.drawn += rec.drawn
|
48
|
-
self.goals_for += rec.goals_for
|
49
|
-
self.goals_against += rec.goals_against
|
50
|
-
self.pts += rec.pts
|
51
|
-
self.recs += rec.recs
|
52
|
-
|
53
|
-
self # return self stats rec
|
54
|
-
end # method add
|
55
|
-
end # class Stats
|
56
|
-
|
57
|
-
|
58
|
-
def self.calc( games, opts={} )
|
59
|
-
|
60
|
-
##
|
61
|
-
# possible opts include:
|
62
|
-
# pts_won: 3 or 2 or n (default 3)
|
63
|
-
# pts_exclude_scorep false or true (default false) -- exclude penalty shotout scores (e.g. count a draw/tie - no winner)
|
64
|
-
#
|
65
|
-
recs = calc_stats( games, opts )
|
66
|
-
|
67
|
-
## update pos (that is, ranking e.g. 1.,2., 3. etc.)
|
68
|
-
recs= update_ranking( recs )
|
69
|
-
|
70
|
-
pp recs
|
71
|
-
recs
|
72
|
-
end
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
def self.calc_for_events( events, opts={} )
|
77
|
-
|
78
|
-
## todo:
|
79
|
-
## - add tracker for appeareances (stats records counter)
|
80
|
-
|
81
|
-
alltime_recs = {} # stats recs indexed by team_key
|
82
|
-
|
83
|
-
events.each do |event|
|
84
|
-
puts " update standings for #{event.title}"
|
85
|
-
recs = calc_stats( event.games, opts )
|
86
|
-
|
87
|
-
recs.each do |team_key, rec|
|
88
|
-
alltime_rec = alltime_recs[ team_key ] || Stats.new
|
89
|
-
|
90
|
-
## add stats values
|
91
|
-
alltime_rec.add( rec )
|
92
|
-
|
93
|
-
alltime_recs[ team_key ] = alltime_rec
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
|
98
|
-
### fix:
|
99
|
-
# - make merge team into a helper method (for reuse)
|
100
|
-
|
101
|
-
## check for merging teams
|
102
|
-
# e.g. all time world cup
|
103
|
-
# Germany incl. West Germany
|
104
|
-
# Russia incl. Soviet Union etc.
|
105
|
-
|
106
|
-
# todo: change opts para to :includes instead of :merge ? why? why not??
|
107
|
-
|
108
|
-
merge = opts[:merge]
|
109
|
-
if merge
|
110
|
-
puts " merging teams (stats records):"
|
111
|
-
pp merge
|
112
|
-
|
113
|
-
merge.each do |k,v|
|
114
|
-
# note: assume key is destition team key and
|
115
|
-
# value is source team key e.g. 'GER' => 'FRG'
|
116
|
-
# or array (for mulitple teamss e.g. 'GER' => ['FRG','GDR']
|
117
|
-
team_key_dest = k.to_s
|
118
|
-
|
119
|
-
if v.kind_of? Array
|
120
|
-
team_keys_src = v
|
121
|
-
else
|
122
|
-
team_keys_src = [v] # turn single value arg into array w/ single item
|
123
|
-
end
|
124
|
-
team_keys_src = team_keys_src.map { |src| src.to_s } # turn all to string (might be symbol)
|
125
|
-
|
126
|
-
alltime_rec_dest = alltime_recs[ team_key_dest ] || Stats.new
|
127
|
-
|
128
|
-
team_keys_src.each do |team_key_src|
|
129
|
-
alltime_rec_src = alltime_recs[ team_key_src]
|
130
|
-
|
131
|
-
if alltime_rec_src # stats record found?
|
132
|
-
alltime_rec_dest.add( alltime_rec_src ) # add stats values
|
133
|
-
alltime_recs.delete( team_key_src ) # remove old src entry
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
alltime_recs[ team_key_dest ] = alltime_rec_dest
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
## update pos (that is, ranking e.g. 1.,2., 3. etc.)
|
142
|
-
alltime_recs= update_ranking( alltime_recs )
|
143
|
-
|
144
|
-
## pp alltime_recs
|
145
|
-
alltime_recs
|
146
|
-
end
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
def self.calc_stats( games, opts={} )
|
151
|
-
|
152
|
-
## fix:
|
153
|
-
# passing in e.g. pts for win (3? 2? etc.)
|
154
|
-
# default to 3 for now
|
155
|
-
|
156
|
-
# note:
|
157
|
-
# returns stats records w/ stats records counter always set to one (recs==1)
|
158
|
-
|
159
|
-
## todo/fix: find a better way to include logger (do NOT hardcode usage of root logger)!!!
|
160
|
-
logger = LogUtils::Logger.root
|
161
|
-
|
162
|
-
|
163
|
-
## lets you pass in 2 as an alterantive, for example
|
164
|
-
pts_won = opts[:pts_won] || 3
|
165
|
-
|
166
|
-
## lets you exclude penalty shootout (e.g. match gets scored as draw/tie 1 pt each)
|
167
|
-
# e.g. why? used for alltime standings formula in world cup, for example
|
168
|
-
# todo: check other standings - exclude penalty shootout too - e.g. championsleague ?? if yes - make it true as default??
|
169
|
-
pts_exclude_scorep = opts[:pts_exclude_scorep].present? ? opts[:pts_exclude_scorep] : false
|
170
|
-
|
171
|
-
|
172
|
-
recs = {}
|
173
|
-
|
174
|
-
games.each_with_index do |g,i| # note: index(i) starts w/ zero (0)
|
175
|
-
puts " [#{i+1}] #{g.team1.title} - #{g.team2.title} #{g.score_str}"
|
176
|
-
unless g.over?
|
177
|
-
puts " !!!! skipping match - not yet over (play_at date in the future)"
|
178
|
-
next
|
179
|
-
end
|
180
|
-
unless g.complete?
|
181
|
-
logger.error "[StandingsHelper.calc_stats] skipping match #{g.team1.title} - #{g.team2.title} - scores incomplete #{g.score_str}"
|
182
|
-
next
|
183
|
-
end
|
184
|
-
|
185
|
-
rec1 = recs[ g.team1.key ] || Stats.new
|
186
|
-
rec2 = recs[ g.team2.key ] || Stats.new
|
187
|
-
|
188
|
-
## set stats records counter to one if new (first) record update
|
189
|
-
rec1.recs = 1 if rec1.recs == 0
|
190
|
-
rec2.recs = 1 if rec2.recs == 0
|
191
|
-
|
192
|
-
rec1.played += 1
|
193
|
-
rec2.played += 1
|
194
|
-
|
195
|
-
## check - if winner (excludes penalty shootout scores in calc? start w/ extra time e.g winneret)
|
196
|
-
if pts_exclude_scorep
|
197
|
-
winner = g.winneret || g.winner90 ## if no extra time (et) score; try 90min (regular time score)
|
198
|
-
else
|
199
|
-
winner = g.winner ## note: might include penalty shoot scores
|
200
|
-
end
|
201
|
-
|
202
|
-
if winner == 1
|
203
|
-
rec1.won += 1
|
204
|
-
rec2.lost += 1
|
205
|
-
rec1.pts += pts_won
|
206
|
-
elsif winner == 2
|
207
|
-
rec1.lost += 1
|
208
|
-
rec2.won += 1
|
209
|
-
rec2.pts += pts_won
|
210
|
-
else ## assume drawn/tie (that is, 0)
|
211
|
-
rec1.drawn += 1
|
212
|
-
rec2.drawn += 1
|
213
|
-
rec1.pts += 1
|
214
|
-
rec2.pts += 1
|
215
|
-
end
|
216
|
-
|
217
|
-
rec1.goals_for += g.score1
|
218
|
-
rec1.goals_against += g.score2
|
219
|
-
|
220
|
-
rec2.goals_for += g.score2
|
221
|
-
rec2.goals_against += g.score1
|
222
|
-
|
223
|
-
## add overtime and penalty??
|
224
|
-
## - for now add only overtime if present
|
225
|
-
|
226
|
-
rec1.goals_for += (g.score1et-g.score1) if g.score1et.present?
|
227
|
-
rec1.goals_against += (g.score2et-g.score2) if g.score2et.present?
|
228
|
-
|
229
|
-
rec2.goals_for += (g.score2et-g.score2) if g.score2et.present?
|
230
|
-
rec2.goals_against += (g.score1et-g.score1) if g.score1et.present?
|
231
|
-
|
232
|
-
recs[ g.team1.key ] = rec1
|
233
|
-
recs[ g.team2.key ] = rec2
|
234
|
-
end # each game
|
235
|
-
|
236
|
-
recs # return records; hash indexed by team key
|
237
|
-
end # method calc
|
238
|
-
|
239
|
-
|
240
|
-
def self.update_ranking( recs )
|
241
|
-
#############################
|
242
|
-
### calc ranking / pos
|
243
|
-
##
|
244
|
-
## fix/allow sampe pos e.g. all 1 or more than one team 3rd etc.
|
245
|
-
## see sportbook for an example
|
246
|
-
|
247
|
-
# build array from hash
|
248
|
-
ary = []
|
249
|
-
recs.each do |k,v|
|
250
|
-
ary << [k,v]
|
251
|
-
end
|
252
|
-
|
253
|
-
ary.sort! do |l,r|
|
254
|
-
## note: reverse order (thus, change l,r to r,l)
|
255
|
-
value = r[1].pts <=> l[1].pts
|
256
|
-
if value == 0 # same pts try goal diff
|
257
|
-
value = (r[1].goals_for-r[1].goals_against) <=> (l[1].goals_for-l[1].goals_against)
|
258
|
-
if value == 0 # same goal diff too; try assume more goals better for now
|
259
|
-
value = r[1].goals_for <=> l[1].goals_for
|
260
|
-
end
|
261
|
-
end
|
262
|
-
value
|
263
|
-
end
|
264
|
-
|
265
|
-
## update pos using ordered array
|
266
|
-
ary.each_with_index do |rec,i|
|
267
|
-
k = rec[0]
|
268
|
-
v = rec[1]
|
269
|
-
v.pos = i+1 ## add ranking (e.g. 1,2,3 etc.) - note: i starts w/ zero (0)
|
270
|
-
recs[ k ] = v ## update recs
|
271
|
-
end
|
272
|
-
|
273
|
-
recs
|
274
|
-
end # method update_ranking
|
275
|
-
|
276
|
-
|
277
|
-
end # module StandingsHelper
|
278
|
-
|
279
|
-
end # module SportDb
|