如果sonar没扫描完成则暂时不读取数据

This commit is contained in:
huang 2016-06-28 22:01:44 +08:00
parent 300ad68405
commit 0a684227b8
1 changed files with 4 additions and 4 deletions

View File

@ -77,12 +77,12 @@ class QualityAnalysisController < ApplicationController
begin
@resource_id = params[:resource_id]
@sonar_address = Redmine::Configuration['sonar_address']
# projects_date = open(@sonar_address + "/api/projects/index").read
# @arr = JSON.parse(projects_date).map {|m| m["nm"]} # ["Hjqreturn:cc_rep", "Hjqreturn:putong", "Hjqreturn:sonar_rep2", "shitou:sonar_rep"]
if params[:resource_id].nil?
@name_flag = true
# @quality_analyses = QualityAnalysis.where("sonar_name in (#{arr.empty? ? '0': arr.join(',')})")
@quality_analyses = QualityAnalysis.where(:project_id => @project.id)
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)
@quality_analyses.collect{|qa| arr.include?(qa.sonar_name)}
else
complexity_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=sqale_rating,function_complexity,duplicated_lines_density,comment_lines_density,sqale_index,lines,file_line,files,functions,classes,directories").read
@complexity =JSON.parse(complexity_date).first