2016-06-24 19:38:08 +08:00
|
|
|
# encoding: utf-8
|
2016-06-21 16:50:45 +08:00
|
|
|
module QualityAnalysisHelper
|
2016-06-23 18:24:22 +08:00
|
|
|
|
|
|
|
def sqale_rating_status val
|
2016-06-24 11:20:39 +08:00
|
|
|
arr = []
|
2016-06-29 14:08:30 +08:00
|
|
|
if val < 5
|
2016-06-24 11:20:39 +08:00
|
|
|
arr << "很好"
|
|
|
|
arr << "b_green2"
|
2016-06-27 18:13:46 +08:00
|
|
|
elsif val. > 5 && val < 10
|
2016-06-24 11:20:39 +08:00
|
|
|
arr << "较好"
|
|
|
|
arr << "b_slow_yellow"
|
2016-06-27 18:13:46 +08:00
|
|
|
elsif val > 10 && val < 20
|
2016-06-24 11:20:39 +08:00
|
|
|
arr << "中等"
|
|
|
|
arr << "b_yellow"
|
2016-06-27 18:13:46 +08:00
|
|
|
elsif val > 20 && val < 50
|
2016-06-24 11:20:39 +08:00
|
|
|
arr << "较差"
|
|
|
|
arr << "b_slow_red"
|
2016-06-27 18:13:46 +08:00
|
|
|
elsif val > 20
|
2016-06-24 11:20:39 +08:00
|
|
|
arr << "很差"
|
|
|
|
arr << "b_red"
|
2016-06-23 18:24:22 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def complexity_status val
|
2016-06-24 11:20:39 +08:00
|
|
|
arr = []
|
2016-06-27 18:13:46 +08:00
|
|
|
if val < 10
|
2016-06-24 11:20:39 +08:00
|
|
|
arr << "良好"
|
|
|
|
arr << "b_green2"
|
2016-06-27 18:13:46 +08:00
|
|
|
elsif val > 10 && val < 15
|
2016-06-24 11:20:39 +08:00
|
|
|
arr << "较高"
|
|
|
|
arr << "b_yellow"
|
2016-06-27 18:13:46 +08:00
|
|
|
elsif val > 15
|
2016-06-24 11:20:39 +08:00
|
|
|
arr << "很高"
|
|
|
|
arr << "b_red"
|
2016-06-23 18:24:22 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def duplicated_lines_density_status val
|
2016-06-24 11:20:39 +08:00
|
|
|
arr = []
|
2016-06-27 18:13:46 +08:00
|
|
|
if val < 30
|
2016-06-24 11:20:39 +08:00
|
|
|
arr << "良好"
|
|
|
|
arr << "b_green2"
|
2016-06-27 18:13:46 +08:00
|
|
|
elsif val > 30 && val < 50
|
2016-06-24 11:20:39 +08:00
|
|
|
arr << "较高"
|
|
|
|
arr << "b_yellow"
|
2016-06-27 18:13:46 +08:00
|
|
|
elsif val > 50
|
2016-06-24 11:20:39 +08:00
|
|
|
arr << "很高"
|
|
|
|
arr << "b_red"
|
2016-06-23 18:24:22 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def comment_lines_density_status val
|
2016-06-24 11:20:39 +08:00
|
|
|
arr = []
|
2016-06-27 18:13:46 +08:00
|
|
|
if val < 20
|
2016-06-24 11:20:39 +08:00
|
|
|
arr << "较低"
|
|
|
|
arr << "b_yellow"
|
2016-06-27 18:13:46 +08:00
|
|
|
elsif val > 20 && val < 50
|
2016-06-24 11:20:39 +08:00
|
|
|
arr << "正常"
|
|
|
|
arr << "b_green2"
|
2016-06-27 18:13:46 +08:00
|
|
|
elsif val > 50
|
2016-06-24 11:20:39 +08:00
|
|
|
arr << "较高"
|
|
|
|
arr << "b_red"
|
2016-06-23 18:24:22 +08:00
|
|
|
end
|
|
|
|
end
|
2016-06-24 09:58:51 +08:00
|
|
|
|
|
|
|
def score_sqale_rating val
|
2016-06-27 18:13:46 +08:00
|
|
|
if val > 0 && val < 5
|
2016-06-24 09:58:51 +08:00
|
|
|
"5"
|
2016-06-27 18:13:46 +08:00
|
|
|
elsif val > 5 && val < 10
|
2016-06-24 09:58:51 +08:00
|
|
|
"4"
|
2016-06-27 18:13:46 +08:00
|
|
|
elsif val > 10 && val < 20
|
2016-06-24 09:58:51 +08:00
|
|
|
"3"
|
2016-06-27 18:13:46 +08:00
|
|
|
elsif val > 20 && val < 50
|
2016-06-24 09:58:51 +08:00
|
|
|
"2"
|
2016-06-27 18:13:46 +08:00
|
|
|
elsif val > 20
|
2016-06-24 09:58:51 +08:00
|
|
|
"1"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def lines_scale val
|
|
|
|
if val.to_i < 5000
|
2016-06-24 10:05:49 +08:00
|
|
|
"小型"
|
2016-06-24 09:58:51 +08:00
|
|
|
elsif val.to_i >5000 && val.to_i < 50000
|
2016-06-24 10:05:49 +08:00
|
|
|
"中型"
|
2016-06-24 09:58:51 +08:00
|
|
|
else
|
2016-06-24 10:05:49 +08:00
|
|
|
"大型"
|
2016-06-24 09:58:51 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-06-24 10:47:21 +08:00
|
|
|
#统计答题百分比,统计结果保留两位小数
|
|
|
|
def statistics_result_percentage(e, t)
|
|
|
|
e = e.to_f
|
|
|
|
t = t.to_f
|
|
|
|
t == 0 ? 0 : format("%.2f", e*100/t)
|
|
|
|
end
|
|
|
|
|
2016-06-21 16:50:45 +08:00
|
|
|
end
|