lx_data_validation 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/data_validation/comparison/comparison_base.rb +73 -22
- data/lib/data_validation/comparison/comparison_factory.rb +1 -1
- data/lib/data_validation/comparison/div_ranking_pr_comparison.rb +1 -1
- data/lib/data_validation/comparison/div_ranking_wl_comparison.rb +8 -0
- data/lib/data_validation/comparison/ranking_table_hs_crr_comparison.rb +4 -0
- data/lib/data_validation/comparison/ranking_table_hs_poll_comparison.rb +4 -0
- data/lib/data_validation/comparison/ranking_table_hs_qwf_comparison.rb +8 -0
- data/lib/data_validation/comparison/ranking_table_hs_rating_comparison.rb +5 -1
- data/lib/data_validation/comparison/ranking_table_hs_rpi_comparison.rb +8 -0
- data/lib/data_validation/comparison/ranking_table_hs_sos_comparison.rb +8 -0
- data/lib/data_validation/comparison/ranking_table_mw_poll_comparison.rb +4 -0
- data/lib/data_validation/comparison/ranking_table_mw_qw_comparison.rb +7 -0
- data/lib/data_validation/comparison/ranking_table_mw_rpi_comparison.rb +8 -0
- data/lib/data_validation/comparison/ranking_table_mw_sos_comparison.rb +4 -0
- data/lib/data_validation/comparison/ranking_table_mw_tsi_comparison.rb +4 -0
- data/lib/data_validation/version.rb +1 -1
- data/lib/data_validation.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be0f66a6383f14c36a771d432383dbdb21af171e
|
4
|
+
data.tar.gz: 2823beb8c72fa58b1f3a9f656cf42419923741f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99fdfd839dafb5ed3ccfa07c99fabb996ab953bed2141942467d0cd3e2233457cf2c069a236911cb57aa6042bc80476938280fa32a85b156c313db51016605f6
|
7
|
+
data.tar.gz: d3fc812ca9464161a839ddafebb22c10f959749e17adb6b7eabd06e9e2935c1b6a206d52dce7c749594f4fa0c8fc2e9ec0e8435d538da9be62ccd9426bb8fac3
|
@@ -37,37 +37,71 @@ module DataValidation
|
|
37
37
|
end
|
38
38
|
|
39
39
|
web_data.each_with_index do |item, index|
|
40
|
-
|
40
|
+
teams = api_data['results']['results']['teams']
|
41
|
+
team = teams[index]
|
41
42
|
|
42
|
-
|
43
|
-
field_array.each do |filed_name|
|
43
|
+
error_log = []
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
elsif filed_name.is_a? Array
|
48
|
-
team_value = team[filed_name[0]][filed_name[1]]
|
49
|
-
else
|
50
|
-
i += 1
|
51
|
-
next
|
52
|
-
end
|
45
|
+
error_info, rank_value = check_item(item, team, false)
|
46
|
+
error_log << error_info
|
53
47
|
|
54
|
-
|
55
|
-
|
56
|
-
|
48
|
+
if error_info.size > 0 && rank_value
|
49
|
+
possible_teams = teams.select { |team| team[rank_field] == rank_value }
|
50
|
+
possible_teams.each do |team|
|
51
|
+
error, value = check_item(item, team, true)
|
52
|
+
error_log << error
|
57
53
|
end
|
54
|
+
end
|
58
55
|
|
56
|
+
error_log.min_by { |log| log.length }.each { |item| logger.error item }
|
57
|
+
end
|
58
|
+
end
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
def check_item(item, team, re_check)
|
61
|
+
error_info = []
|
62
|
+
i = 0
|
63
|
+
rank_value = nil # the value used to rank
|
63
64
|
|
64
|
-
|
65
|
-
|
65
|
+
field_array.each do |field_name|
|
66
|
+
|
67
|
+
if re_check && field_name == related_rank_field
|
68
|
+
i += 1
|
69
|
+
next
|
70
|
+
end
|
66
71
|
|
72
|
+
if field_name.is_a? String
|
73
|
+
team_value = team[field_name]
|
74
|
+
elsif field_name.is_a? Array
|
75
|
+
team_value = team[field_name[0]][field_name[1]]
|
76
|
+
else
|
67
77
|
i += 1
|
78
|
+
next
|
79
|
+
end
|
80
|
+
|
81
|
+
if item.length < field_array.length && empty_field && empty_field == field_name ## when the field is empty in the table
|
82
|
+
error_info << "team #{item[0]}'s #{field_name} is not empty: #{team_value}" unless (team_value == 0 || team_value.nil?)
|
83
|
+
next
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
if compare_values(item[i], team_value)
|
88
|
+
|
89
|
+
if field_name == rank_field
|
90
|
+
rank_value = team_value
|
91
|
+
end
|
92
|
+
else
|
93
|
+
error_info << "team #{item[0]}'s #{field_name}: #{item[i]} -- #{team_value}"
|
68
94
|
end
|
69
95
|
|
96
|
+
i += 1
|
70
97
|
end
|
98
|
+
[error_info, rank_value]
|
99
|
+
end
|
100
|
+
|
101
|
+
def compare_values(page_item, team_value)
|
102
|
+
(team_value.is_a?(String) && team_value.include?(page_item.strip)) ||
|
103
|
+
(team_value.is_a?(Float) && compare_floats(team_value, page_item)) ||
|
104
|
+
(team_value.is_a?(Integer) && team_value == page_item.to_i)
|
71
105
|
end
|
72
106
|
|
73
107
|
def compare_conf_standings(api_data, data_access)
|
@@ -95,7 +129,7 @@ module DataValidation
|
|
95
129
|
|
96
130
|
record.each_with_index do |item, index|
|
97
131
|
if index == 0 && item.to_i != team_data['rank']
|
98
|
-
elsif index == 1 &&
|
132
|
+
elsif index == 1 && !compare_floats(team_data['powerRating'], item)
|
99
133
|
logger.error "team #{i} powerRating in #{full_conf}: #{item.to_f} -- #{team_data['powerRating']}"
|
100
134
|
elsif index == 2 && item.to_i != team_data['conference']['wins']
|
101
135
|
logger.error "team #{i} conference wins in #{full_conf}: #{item.to_i} -- #{team_data['conference']['wins']}"
|
@@ -103,7 +137,7 @@ module DataValidation
|
|
103
137
|
logger.error "team #{i} conference losses in #{full_conf}: #{item.to_i} -- #{team_data['conference']['losses']}"
|
104
138
|
elsif index == 4 && item.to_i != team_data['conference']['ties']
|
105
139
|
logger.error "team #{i} conference ties in #{full_conf}: #{item.to_i} -- #{team_data['conference']['ties']}"
|
106
|
-
elsif index == 5 &&
|
140
|
+
elsif index == 5 && !compare_floats(team_data['winLossConf'], item)
|
107
141
|
logger.error "team #{i} winLossConf in #{full_conf}: #{item.to_f} -- #{team_data['winLossConf']}"
|
108
142
|
elsif index == 6 && item.to_i != team_data['total']['wins']
|
109
143
|
logger.error "team #{i} total wins in #{full_conf}: #{item.to_i} -- #{team_data['total']['wins']}"
|
@@ -111,7 +145,7 @@ module DataValidation
|
|
111
145
|
logger.error "team #{i} total losses in #{full_conf}: #{item.to_i} -- #{team_data['total']['losses']}"
|
112
146
|
elsif index == 8 && item.to_i != team_data['total']['ties']
|
113
147
|
logger.error "team #{i} total ties in #{full_conf}: #{item.to_i} -- #{team_data['total']['ties']}"
|
114
|
-
elsif index == 9 &&
|
148
|
+
elsif index == 9 && !compare_floats(team_data['winLossTotal'], item)
|
115
149
|
logger.error "team #{i} winLossTotal in #{full_conf}: #{item.to_f} -- #{team_data['winLossTotal']}"
|
116
150
|
end
|
117
151
|
end
|
@@ -135,6 +169,14 @@ module DataValidation
|
|
135
169
|
|
136
170
|
end
|
137
171
|
|
172
|
+
def rank_field
|
173
|
+
|
174
|
+
end
|
175
|
+
|
176
|
+
def related_rank_field
|
177
|
+
|
178
|
+
end
|
179
|
+
|
138
180
|
def determine_request_body_and_logger_name
|
139
181
|
@category = if web_url.match /bingrl/
|
140
182
|
'GIRLS'
|
@@ -157,6 +199,15 @@ module DataValidation
|
|
157
199
|
%Q|{"category":"#{category}","season":#{season},"divisionId":#{division_id},"currPage":1,"pageSize":1000}|
|
158
200
|
end
|
159
201
|
|
202
|
+
def compare_floats(team_value, page_item)
|
203
|
+
f = page_item.to_f
|
204
|
+
(team_value - f).round(decimal_places_num) <= 0.01
|
205
|
+
end
|
206
|
+
|
207
|
+
def decimal_places_num
|
208
|
+
2
|
209
|
+
end
|
210
|
+
|
160
211
|
private
|
161
212
|
|
162
213
|
def logger
|
@@ -39,7 +39,7 @@ module DataValidation
|
|
39
39
|
return RankingTableMwPollComparison.new url
|
40
40
|
elsif url.match /update\d\d\/bin\S+\/trend\d+.php/ # Trend page for collage division
|
41
41
|
return RankingTableMwTrendComparison.new url
|
42
|
-
elsif url.match /update\d\d\/bin\S+\/tsi\d+.php/ #
|
42
|
+
elsif url.match /update\d\d\/bin\S+\/tsi\d+.php/ # Tournament Selection Index page for collage division
|
43
43
|
return RankingTableMwTsiComparison.new url
|
44
44
|
elsif url.match /\.com\/(mll|nll)/ # Pro ranking page
|
45
45
|
return RankingTableProPrComparison.new url
|
@@ -52,7 +52,7 @@ module DataValidation
|
|
52
52
|
|
53
53
|
|
54
54
|
unless (team_value.is_a?(String) && team_value.include?(item[i])) ||
|
55
|
-
(team_value.is_a?(Float) && team_value
|
55
|
+
(team_value.is_a?(Float) && compare_floats(team_value, item[i])) ||
|
56
56
|
(team_value.is_a?(Integer) && team_value == item[i].to_i)
|
57
57
|
|
58
58
|
logger.error "team #{item[0]}'s #{filed_name}: #{item[i]} -- #{team_value}"
|
@@ -12,6 +12,14 @@ module DataValidation
|
|
12
12
|
['rank', 'teamName', 'rank', 'winLossTotal', 'rankDivision', 'winLossDivision', 'rankDate', 'winLossDate', 'rankRoad', 'winLossRoad', %w|record wins|, %w|record losses|, %w|record ties|]
|
13
13
|
end
|
14
14
|
|
15
|
+
def rank_field
|
16
|
+
'winLossTotal'
|
17
|
+
end
|
18
|
+
|
19
|
+
def related_rank_field
|
20
|
+
'rank'
|
21
|
+
end
|
22
|
+
|
15
23
|
end
|
16
24
|
end
|
17
25
|
end
|
@@ -8,6 +8,14 @@ module DataValidation
|
|
8
8
|
['rank', 'teamName', 'region', 'gameScheduled', 'qwf', 'totalWins', 'totalLosses', 'totalTies']
|
9
9
|
end
|
10
10
|
|
11
|
+
def rank_field
|
12
|
+
'qwf'
|
13
|
+
end
|
14
|
+
|
15
|
+
def related_rank_field
|
16
|
+
'rank'
|
17
|
+
end
|
18
|
+
|
11
19
|
def determine_request_body_and_logger_name
|
12
20
|
@category = if web_url.match /bingrl/
|
13
21
|
'GIRLS'
|
@@ -12,6 +12,10 @@ module DataValidation
|
|
12
12
|
'pollRank'
|
13
13
|
end
|
14
14
|
|
15
|
+
def rank_field
|
16
|
+
'powerRating'
|
17
|
+
end
|
18
|
+
|
15
19
|
def determine_request_body_and_logger_name
|
16
20
|
@category = if web_url.match /bingrl/
|
17
21
|
'GIRLS'
|
@@ -27,7 +31,7 @@ module DataValidation
|
|
27
31
|
|
28
32
|
@logger_name = "log/#{season}/#{category.downcase}/natlrating_#{season}_#{category}.log"
|
29
33
|
|
30
|
-
%Q|{"category":"#{category}","season":#{season}, "type": "PR", "currPage":1,"pageSize":
|
34
|
+
%Q|{"category":"#{category}","season":#{season}, "type": "PR", "currPage":1,"pageSize":5000}|
|
31
35
|
end
|
32
36
|
|
33
37
|
end
|
@@ -12,6 +12,13 @@ module DataValidation
|
|
12
12
|
['rank', 'teamName', 'qwPrRank', 'qualityWinsPr', nil, 'qualityWinsPoll', 'qwRpiRank', 'qualityWinsRpi', %w|record wins|, %w|record losses|, %w|record ties|]
|
13
13
|
end
|
14
14
|
|
15
|
+
def rank_field
|
16
|
+
'qualityWinsPr'
|
17
|
+
end
|
18
|
+
|
19
|
+
def related_rank_field
|
20
|
+
'qwPrRank'
|
21
|
+
end
|
15
22
|
end
|
16
23
|
end
|
17
24
|
end
|
@@ -12,6 +12,10 @@ module DataValidation
|
|
12
12
|
['rank', 'teamName', 'totalGames', nil, 'sosAverage', 'sosWeightedRank', 'sosWeighted', 'sosRpiRank', 'sosRpi', %w|record wins|, %w|record losses|, %w|record ties|]
|
13
13
|
end
|
14
14
|
|
15
|
+
def rank_field
|
16
|
+
'sosAverage'
|
17
|
+
end
|
18
|
+
|
15
19
|
end
|
16
20
|
end
|
17
21
|
end
|
data/lib/data_validation.rb
CHANGED
@@ -23,6 +23,7 @@ module DataValidation
|
|
23
23
|
def compare_with_season(season = '17')
|
24
24
|
compare_with_url(web_request_host + '/mll')
|
25
25
|
compare_with_url(web_request_host + '/nll')
|
26
|
+
compare_national(season)
|
26
27
|
%w|men women boys girls|.each { |category| compare_with_season_and_category season, category }
|
27
28
|
end
|
28
29
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lx_data_validation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roger Tong
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|