lx_data_validation 0.0.10 → 0.0.11

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: 02c93750ed26cb06f116a642b68edc23fc709043
4
- data.tar.gz: bd936e31f2744b45648ee733378d502c8cbed2cc
3
+ metadata.gz: be0f66a6383f14c36a771d432383dbdb21af171e
4
+ data.tar.gz: 2823beb8c72fa58b1f3a9f656cf42419923741f4
5
5
  SHA512:
6
- metadata.gz: 7a03048a35904537093fda7db90d00af6287d3a8f05fba9d7d9cca0e2ce7a076853bb04f2d709d1d273d60847c01f06e639e8b2d6db70c4e1f8b3cc143d800d0
7
- data.tar.gz: b5b07349608f919c5288fc90b557c1ddc7803ddc9e037ce777be768b99a9a9e99f1c94efe1b5b3c2e98a67e8472c00be8b04a118055059d15bb4327b6a38716a
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
- team = api_data['results']['results']['teams'][index]
40
+ teams = api_data['results']['results']['teams']
41
+ team = teams[index]
41
42
 
42
- i = 0
43
- field_array.each do |filed_name|
43
+ error_log = []
44
44
 
45
- if filed_name.is_a? String
46
- team_value = team[filed_name]
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
- if item.length < field_array.length && empty_field && empty_field == filed_name ## when the field is empty in the table
55
- logger.error "team #{item[0]}'s #{filed_name} is not empty: #{team_value}" unless (team_value == 0 || team_value.nil?)
56
- next
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
- unless (team_value.is_a?(String) && team_value.include?(item[i].strip)) ||
61
- (team_value.is_a?(Float) && team_value == item[i].to_f) ||
62
- (team_value.is_a?(Integer) && team_value == item[i].to_i)
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
- logger.error "team #{item[0]}'s #{filed_name}: #{item[i]} -- #{team_value}"
65
- end
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 && item.to_f != team_data['powerRating']
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 && item.to_f != team_data['winLossConf']
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 && item.to_f != team_data['winLossTotal']
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/ # Trend page for collage division
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 == item[i].to_f) ||
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,10 @@ module DataValidation
8
8
  ['rank', 'teamName', 'state', 'totalWins', 'totalLosses', 'totalTies', 'ccr', 'pollPoint', 'powerRating']
9
9
  end
10
10
 
11
+ def rank_field
12
+ 'ccr'
13
+ end
14
+
11
15
  end
12
16
  end
13
17
  end
@@ -8,6 +8,10 @@ module DataValidation
8
8
  ['rank', 'teamName', 'state', 'totalWins', 'totalLosses', 'totalTies', 'pollPoint', 'pollFirst']
9
9
  end
10
10
 
11
+ def rank_field
12
+ 'pollFirst'
13
+ end
14
+
11
15
  end
12
16
  end
13
17
  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":1000}|
34
+ %Q|{"category":"#{category}","season":#{season}, "type": "PR", "currPage":1,"pageSize":5000}|
31
35
  end
32
36
 
33
37
  end
@@ -8,6 +8,14 @@ module DataValidation
8
8
  ['rank', 'teamName', 'region', 'gameScheduled', 'rpi', 'totalWins', 'totalLosses', 'totalTies']
9
9
  end
10
10
 
11
+ def rank_field
12
+ 'rpi'
13
+ end
14
+
15
+ def related_rank_field
16
+ 'rank'
17
+ end
18
+
11
19
  end
12
20
  end
13
21
  end
@@ -8,6 +8,14 @@ module DataValidation
8
8
  ['rank', 'teamName', 'region', 'gameScheduled', 'sos', 'totalWins', 'totalLosses', 'totalTies']
9
9
  end
10
10
 
11
+ def rank_field
12
+ 'sos'
13
+ end
14
+
15
+ def related_rank_field
16
+ 'rank'
17
+ end
18
+
11
19
  end
12
20
  end
13
21
  end
@@ -16,6 +16,10 @@ module DataValidation
16
16
  'pollFirst'
17
17
  end
18
18
 
19
+ def rank_field
20
+ 'pollPoint'
21
+ end
22
+
19
23
  end
20
24
  end
21
25
  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
@@ -16,6 +16,14 @@ module DataValidation
16
16
  %w|recordHome wins|, %w|recordHome losses|, %w|recordHome ties|]
17
17
  end
18
18
 
19
+ def rank_field
20
+ 'rpi'
21
+ end
22
+
23
+ def decimal_places_num
24
+ 4
25
+ end
26
+
19
27
  end
20
28
  end
21
29
  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
@@ -16,6 +16,10 @@ module DataValidation
16
16
  'pollRank'
17
17
  end
18
18
 
19
+ def rank_field
20
+ 'tsi'
21
+ end
22
+
19
23
  end
20
24
  end
21
25
  end
@@ -1,3 +1,3 @@
1
1
  module DataValidation
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
@@ -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.10
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-03-17 00:00:00.000000000 Z
11
+ date: 2017-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri