From a3ba5089139cb181cbf8523ed71e8a31e225e4f9 Mon Sep 17 00:00:00 2001 From: Martijn Stegeman Date: Wed, 22 May 2019 16:50:54 +0200 Subject: [PATCH] fix for checkpy --- app/models/submit.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/models/submit.rb b/app/models/submit.rb index fde3f5cc..4c4c83b4 100644 --- a/app/models/submit.rb +++ b/app/models/submit.rb @@ -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