From cb148c3b9c124b6d03a1e88a0f2b1bcd13920dac Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 11 Jul 2016 10:48:44 +0800 Subject: [PATCH 1/5] fixed 500 --- .../quality_analysis_controller.rb | 6 ++-- app/helpers/quality_analysis_helper.rb | 30 +++++++++---------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb index db5fac9c7..f59f6df4d 100644 --- a/app/controllers/quality_analysis_controller.rb +++ b/app/controllers/quality_analysis_controller.rb @@ -213,7 +213,8 @@ class QualityAnalysisController < ApplicationController @quality_analyses = QualityAnalysis.where(:project_id => @project.id).select{|qa| arr.include?(qa.sonar_name)} else filter = "sqale_rating,function_complexity,duplicated_lines_density,comment_lines_density,sqale_index,lines,files,functions,classes,directories,blocker_violations,critical_violations,major_violations,minor_violations,info_violations,violations" - complexity_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=#{filter}").read + # complexity_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=#{filter}").read + complexity_date = open("http://sonar.trustie.net" + "/api/resources/index?resource=947&depth=0&metrics=#{filter}").read @complexity =JSON.parse(complexity_date).first # 按名称转换成hash键值对 @@ -227,9 +228,6 @@ class QualityAnalysisController < ApplicationController end @ha.store(key,value) end - - issue_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=blocker_violations,critical_violations,major_violations,minor_violations,info_violations,violations").read - @sonar_issues = JSON.parse(issue_date).first end rescue => e puts e diff --git a/app/helpers/quality_analysis_helper.rb b/app/helpers/quality_analysis_helper.rb index 2a7d350e7..5940dd255 100644 --- a/app/helpers/quality_analysis_helper.rb +++ b/app/helpers/quality_analysis_helper.rb @@ -3,16 +3,16 @@ module QualityAnalysisHelper def sqale_rating_status val arr = [] - if val < 5 + if val <= 5 arr << "很好" arr << "b_green2" - elsif val. > 5 && val < 10 + elsif val. > 5 && val <= 10 arr << "较好" arr << "b_slow_yellow" - elsif val > 10 && val < 20 + elsif val > 10 && val <= 20 arr << "中等" arr << "b_yellow" - elsif val > 20 && val < 50 + elsif val > 20 && val <= 50 arr << "较差" arr << "b_slow_red" elsif val > 20 @@ -23,10 +23,10 @@ module QualityAnalysisHelper def complexity_status val arr = [] - if val < 10 + if val <= 10 arr << "良好" arr << "b_green2" - elsif val > 10 && val < 15 + elsif val > 10 && val <= 15 arr << "较高" arr << "b_yellow" elsif val > 15 @@ -37,10 +37,10 @@ module QualityAnalysisHelper def duplicated_lines_density_status val arr = [] - if val < 30 + if val <= 30 arr << "良好" arr << "b_green2" - elsif val > 30 && val < 50 + elsif val > 30 && val <= 50 arr << "较高" arr << "b_yellow" elsif val > 50 @@ -51,10 +51,10 @@ module QualityAnalysisHelper def comment_lines_density_status val arr = [] - if val < 20 + if val <= 20 arr << "较低" arr << "b_yellow" - elsif val > 20 && val < 50 + elsif val > 20 && val <= 50 arr << "正常" arr << "b_green2" elsif val > 50 @@ -64,15 +64,15 @@ module QualityAnalysisHelper end def score_sqale_rating val - if val > 0 && val < 5 + if val >= 0 && val <= 5 "5" - elsif val > 5 && val < 10 + elsif val > 5 && val <= 10 "4" - elsif val > 10 && val < 20 + elsif val > 10 && val <= 20 "3" - elsif val > 20 && val < 50 + elsif val > 20 && val <= 50 "2" - elsif val > 20 + elsif val > 50 "1" end end From 831006f3c6af21676764a371601832631aee9e9e Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 11 Jul 2016 10:57:46 +0800 Subject: [PATCH 2/5] css for sqale_index --- app/controllers/quality_analysis_controller.rb | 3 +-- app/views/quality_analysis/_show.html.erb | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb index f59f6df4d..a7bf0ef73 100644 --- a/app/controllers/quality_analysis_controller.rb +++ b/app/controllers/quality_analysis_controller.rb @@ -213,8 +213,7 @@ class QualityAnalysisController < ApplicationController @quality_analyses = QualityAnalysis.where(:project_id => @project.id).select{|qa| arr.include?(qa.sonar_name)} else filter = "sqale_rating,function_complexity,duplicated_lines_density,comment_lines_density,sqale_index,lines,files,functions,classes,directories,blocker_violations,critical_violations,major_violations,minor_violations,info_violations,violations" - # complexity_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=#{filter}").read - complexity_date = open("http://sonar.trustie.net" + "/api/resources/index?resource=947&depth=0&metrics=#{filter}").read + complexity_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=#{filter}").read @complexity =JSON.parse(complexity_date).first # 按名称转换成hash键值对 diff --git a/app/views/quality_analysis/_show.html.erb b/app/views/quality_analysis/_show.html.erb index 347f33cb5..f36b72d10 100644 --- a/app/views/quality_analysis/_show.html.erb +++ b/app/views/quality_analysis/_show.html.erb @@ -58,17 +58,17 @@ 可定性评价为:质量<%= @ha["sqale_rating"].nil? ? "很好" : sqale_rating_status(@ha["sqale_rating"].to_i)[0] %>
技术债务 - + <% if @ha["sqale_index"].to_i == 0 %> - 0 + 0天 <% else %> <%= /[0-9]*/.match(@ha["sqale_index"])[0] %>天 - <%= / [0-9]*/.match(@ha["sqale_index"]).nil? ? 0 : / [0-9]*/.match(@ha["sqale_index"]) %>小时 + <%= / [0-9]*/.match(@ha["sqale_index"]).nil? ? "" : / [0-9]*/.match(@ha["sqale_index"])+"小时" %> <% end %> 查看详情
-
质量问题 - +
 质量问题 + <%= @ha["violations"].nil? ? 0 : @ha["violations"] %> From bac3e433aad63d10988d8607939b741065b89ba7 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 11 Jul 2016 11:07:04 +0800 Subject: [PATCH 3/5] sqlate index nil --- app/views/quality_analysis/_show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/quality_analysis/_show.html.erb b/app/views/quality_analysis/_show.html.erb index f36b72d10..0f5aebc2d 100644 --- a/app/views/quality_analysis/_show.html.erb +++ b/app/views/quality_analysis/_show.html.erb @@ -63,7 +63,7 @@ 0天 <% else %> <%= /[0-9]*/.match(@ha["sqale_index"])[0] %>天 - <%= / [0-9]*/.match(@ha["sqale_index"]).nil? ? "" : / [0-9]*/.match(@ha["sqale_index"])+"小时" %> + <%= / [0-9]*/.match(@ha["sqale_index"]).nil? ? "" : (/ [0-9]*/.match(@ha["sqale_index"]).to_s + "小时") %> <% end %> 查看详情
From 93e79d9419201bb054e177c23df3dc783639b009 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 11 Jul 2016 11:23:59 +0800 Subject: [PATCH 4/5] add hidden to css --- app/views/quality_analysis/_result_list.html.erb | 8 ++++---- public/stylesheets/project.css | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/views/quality_analysis/_result_list.html.erb b/app/views/quality_analysis/_result_list.html.erb index b0b8abafe..3e2a7d373 100644 --- a/app/views/quality_analysis/_result_list.html.erb +++ b/app/views/quality_analysis/_result_list.html.erb @@ -17,10 +17,10 @@ <% if @quality_analyses.count >0 %> <% @quality_analyses.each do |qa| %>
    -
  • <%=link_to "#{qa.author_login}:#{qa.rep_identifier}", project_quality_analysis_path(:resource_id => qa.sonar_name, :branch => (qa.branch.nil? ? "master" : qa.branch)), :class => "analysis-result-name fl fontBlue2" %>
  • -
  • <%= qa.branch %>
  • -
  • <%= qa.language %>
  • -
  • <%= qa.path %>
  • +
  • <%=link_to "#{qa.author_login}:#{qa.rep_identifier}", project_quality_analysis_path(:resource_id => qa.sonar_name, :branch => (qa.branch.nil? ? "master" : qa.branch)), :class => "analysis-result-name fl fontBlue2 hidden" %>
  • + + + <% if User.current.try(:login) == qa.author_login %>
  • <%=link_to "编辑", edit_project_quality_analysi_path(qa, :project_id => @project.id), :remote => true, :class => "fontBlue2" %> diff --git a/public/stylesheets/project.css b/public/stylesheets/project.css index bde560613..9a3ba2e47 100644 --- a/public/stylesheets/project.css +++ b/public/stylesheets/project.css @@ -1273,11 +1273,11 @@ a.pages-big{ width:50px;} .analysis-result-list {padding:5px;} .analysis-result-list:nth-of-type(odd){background:#fff;}/*奇数行*/ .analysis-result-list:nth-of-type(even){background:#f5f5f5;}/*偶数行*/ -.analysis-result-name {width:200px; cursor:pointer;} -.analysis-result-version {width:90px; text-align:right; cursor:pointer;} -.analysis-result-loc {width:60px; text-align:right; cursor:pointer;} -.analysis-result-debt {width:160px; text-align:right; cursor:pointer;} -.analysis-result-time {width:150px; text-align:right; cursor:pointer;} +.analysis-result-name {width:200px;} +.analysis-result-version {width:90px; text-align:right;} +.analysis-result-loc {width:60px; text-align:right;} +.analysis-result-debt {width:160px; text-align:right;} +.analysis-result-time {width:150px; text-align:right;} .analysis-name-icon {background:url(../images/code-analysis-icon.png) -2px -148px no-repeat; width:16px; height:16px; display:inline-block; vertical-align:middle;} /*未登录回复提示*/ From 0a001b4f768a3b026d2fabdcbdf25948f8d9a3db Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 11 Jul 2016 11:29:15 +0800 Subject: [PATCH 5/5] message 500 for boliang --- app/views/users/_join_course_course_message.html.erb | 2 +- app/views/users/_user_message_course.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/users/_join_course_course_message.html.erb b/app/views/users/_join_course_course_message.html.erb index 01ebb5cf9..c7d1157f9 100644 --- a/app/views/users/_join_course_course_message.html.erb +++ b/app/views/users/_join_course_course_message.html.erb @@ -18,7 +18,7 @@

    真实姓名:<%= User.find(ma.course_message_id).realname %>

    申请课程:<%= Course.find(ma.course_id).name%>

    课程描述:
    -
    <%= Course.find(ma.course_id).description.html_safe %>
    +
    <%= Course.find(ma.course_id).description %>

    申请职位:<%= ma.content == '9' ? "教师" : "教辅"%>

  • diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index f48ce7010..5702d61d1 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -569,7 +569,7 @@
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> - <% if ma.course_message_type == "JoinCourseRequest" %> + <% if ma.course_message_type == "JoinCourseRequest" && !ma.nil? %>
      <%= render :partial => 'join_course_course_message', :locals => {:ma => ma} %>