Skip to content

Commit

Permalink
fix for checkpy
Browse files Browse the repository at this point in the history
  • Loading branch information
stgm committed May 22, 2019
1 parent f563f5e commit a3ba508
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions app/models/submit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,21 @@ def automatic
def check_score
check_results = JSON(self.check_results)
check_results.keys.each do |tool|
puts tool
puts check_results[tool].inspect
case tool
when "check50v2"
return check_results[tool].count { |x| x["status"].present? } / check_results[tool].size.to_f
when "check50v3"
return check_results[tool]["results"].count { |x| x["passed"].present? } / check_results[tool]["results"].size.to_f
when "checkpy" && check_results[tool].is_a?(Array)
return check_results[tool].collect { |f| f["nPassed"] }.sum
when "checkpy" && check_results[tool].is_a?(Hash)
return [check_results[tool]].collect { |f| f["nPassed"] }.sum
when "checkpy"
if check_results[tool].is_a?(Array)
puts "arr"
return check_results[tool].collect { |f| f["nPassed"] }.sum
elsif check_results[tool].is_a?(Hash)
puts "hash"
return [check_results[tool]].collect { |f| f["nPassed"] }.sum
end
end
end

Expand Down

0 comments on commit a3ba508

Please sign in to comment.