Merge branch 'rep_quality' of https://git.trustie.net/jacknudt/trustieforge into rep_quality

This commit is contained in:
Your Name 2016-06-29 09:11:13 +08:00
commit 3c3fb29bb2
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