diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb index c7b7ecd5d..5f3fac9ac 100644 --- a/app/controllers/quality_analysis_controller.rb +++ b/app/controllers/quality_analysis_controller.rb @@ -225,43 +225,43 @@ class QualityAnalysisController < ApplicationController @branch = params[:branch] @resource_id = params[:resource_id] @sonar_address = Redmine::Configuration['sonar_address'] - if params[:resource_id].nil? - @name_flag = true - projects_date = open(@sonar_address + "/api/projects/index").read - arr = JSON.parse(projects_date).map {|m| m["nm"]} # eg: ["Hjqreturn:cc_rep", "Hjqreturn:putong", "Hjqreturn:sonar_rep2", "shitou:sonar_rep"] - @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 =JSON.parse(complexity_date).first - logger.info("######################################complexity is #{@complexity}") - # 获取排名结果 - # @g = Gitlab.client - # @author_infos = @g.rep_user_stats(@project.gpid, :rev => @branch) - # @user_quality_infos = [] - # @author_infos.each do |author_info| - # email = author_info.email - # changes = author_info.changes.to_i - # unresolved_issues = open(URI::escape(@sonar_address + "/api/issues/search?projectKeys=#{@resource_id}&authors=#{email}&resolved=false")).read - # unresolved_issue_count = JSON.parse(unresolved_issues)["total"].to_i - # all_issues = open(URI::escape(@sonar_address + "/api/issues/search?projectKeys=#{@resource_id}&authors=#{email}")).read - # all_issue_count = JSON.parse(all_issues)["total"].to_i - # ratio = ((changes == 0 || all_issue_count == 0) ? 0 : format("%0.4f",all_issue_count.to_f/changes.to_f)) - # @user_quality_infos << {:email => email, :changes => changes, :unresolved_issue_count => unresolved_issue_count, :ratio => ratio, :all_issue_count => all_issue_count} - # end - - # 按名称转换成hash键值对 - @ha = {} - @complexity["msr"].each do |com| - key = com["key"] - if key == "sqale_index" - value = com["frmt_val"] - else - value = com["val"] - end - @ha.store(key,value) - end - end + # if params[:resource_id].nil? + @name_flag = true + projects_date = open(@sonar_address + "/api/projects/index").read + arr = JSON.parse(projects_date).map {|m| m["nm"]} # eg: ["Hjqreturn:cc_rep", "Hjqreturn:putong", "Hjqreturn:sonar_rep2", "shitou:sonar_rep"] + @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 =JSON.parse(complexity_date).first + # # logger.info("######################################complexity is #{@complexity}") + # # 获取排名结果 + # # @g = Gitlab.client + # # @author_infos = @g.rep_user_stats(@project.gpid, :rev => @branch) + # # @user_quality_infos = [] + # # @author_infos.each do |author_info| + # # email = author_info.email + # # changes = author_info.changes.to_i + # # unresolved_issues = open(URI::escape(@sonar_address + "/api/issues/search?projectKeys=#{@resource_id}&authors=#{email}&resolved=false")).read + # # unresolved_issue_count = JSON.parse(unresolved_issues)["total"].to_i + # # all_issues = open(URI::escape(@sonar_address + "/api/issues/search?projectKeys=#{@resource_id}&authors=#{email}")).read + # # all_issue_count = JSON.parse(all_issues)["total"].to_i + # # ratio = ((changes == 0 || all_issue_count == 0) ? 0 : format("%0.4f",all_issue_count.to_f/changes.to_f)) + # # @user_quality_infos << {:email => email, :changes => changes, :unresolved_issue_count => unresolved_issue_count, :ratio => ratio, :all_issue_count => all_issue_count} + # # end + # + # # 按名称转换成hash键值对 + # # @ha = {} + # # @complexity["msr"].each do |com| + # # key = com["key"] + # # if key == "sqale_index" + # # value = com["frmt_val"] + # # else + # # value = com["val"] + # # end + # # @ha.store(key,value) + # # end + # end rescue Exception => e logger.error("fatal################# #{e}") end diff --git a/app/views/quality_analysis/_result_list.html.erb b/app/views/quality_analysis/_result_list.html.erb index 135e59621..55558a3ce 100644 --- a/app/views/quality_analysis/_result_list.html.erb +++ b/app/views/quality_analysis/_result_list.html.erb @@ -20,7 +20,11 @@ <% if @quality_analyses && @quality_analyses.count > 0 %> <% @quality_analyses.each do |qa| %> - <%=link_to qa.sonar_name, project_quality_analysis_path(:resource_id => qa.sonar_name, :branch => (qa.branch.nil? ? "master" : qa.branch)), :class => "analysis-result-name fl fontBlue2 hidden" %> + + " class="analysis-result-name fl fontBlue2 hidden" target="_blank"> + <%= qa.sonar_name %> + + <%#=link_to qa.sonar_name, project_quality_analysis_path(:resource_id => qa.sonar_name, :branch => (qa.branch.nil? ? "master" : qa.branch)), :class => "analysis-result-name fl fontBlue2 hidden" %> <%= qa.branch %> <%= qa.language %> <%= qa.path %>