From 3fe5d9a1a31d164cd12376a4524ac9b5d218e97b Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 23 Jun 2016 11:24:58 +0800 Subject: [PATCH] get date froma sonar --- .../quality_analysis_controller.rb | 8 +-- app/views/quality_analysis/_show.html.erb | 70 +++++-------------- app/views/quality_analysis/index.html.erb | 2 +- .../repositories/_quality_analysis.html.erb | 12 ++-- .../repositories/quality_analysis.js.erb | 2 +- 5 files changed, 30 insertions(+), 64 deletions(-) diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb index 6be51da70..fd000aa72 100644 --- a/app/controllers/quality_analysis_controller.rb +++ b/app/controllers/quality_analysis_controller.rb @@ -53,15 +53,15 @@ class QualityAnalysisController < ApplicationController end def index - if params[:name].nil? + if params[:resource_id].nil? @name_flag = true projects_date = open("http://123.59.135.93:8891/api/projects/index").read @results = JSON.parse(projects_date) else @name_flag = false - project_key = params[:name] - data = open("http://123.59.135.93:8891/api/resources/index?resource=#{project_key}&depth=-1&metrics=complexity,class_complexity,lines,comment_lines,blocker_violations").read - @cc =JSON.parse(data) + resource_id = params[:resource_id] + complexity_date = open("http://123.59.135.93:8891/api/resources/index?resource=139&depth=0&metrics=complexity,function_complexity,class_complexity,file_complexity,lines,file_line,files,functions,classes,directories").read + @complexity =JSON.parse(complexity_date).first end end diff --git a/app/views/quality_analysis/_show.html.erb b/app/views/quality_analysis/_show.html.erb index 4cb86f22c..46a5e2e3d 100644 --- a/app/views/quality_analysis/_show.html.erb +++ b/app/views/quality_analysis/_show.html.erb @@ -1,51 +1,20 @@ -
+

lines: <%= @complexity["msr"][0]["frmt_val"] %>

+

files: <%= @complexity["msr"][2]["frmt_val"] %>

+

directories: <%= @complexity["msr"][3]["frmt_val"] %>

+

classes: <%= @complexity["msr"][1]["frmt_val"] %>

+

function: <%= @complexity["msr"][4]["frmt_val"] %>

+

total Complexity: <%= @complexity["msr"][5]["frmt_val"] %>

+

file_complexity: <%= @complexity["msr"][6]["frmt_val"] %>

+

class_complexity: <%= @complexity["msr"][7]["frmt_val"] %>

+

function_complexity: <%= @complexity["msr"][8]["frmt_val"] %>

+ + + +

SonarQube质量分析

-
-
- - 分支: - -
-
- 开始分析 + branch:master
项目代码质量分析报告
概要信息
@@ -83,23 +52,23 @@

代码行数

-

9,337

+

<%= @complexity["msr"][0]["frmt_val"] %>

文件

-

10

+

<%= @complexity["msr"][2]["frmt_val"] %>

目录

-

6

+

<%= @complexity["msr"][3]["frmt_val"] %>

-

15

+

<%= @complexity["msr"][1]["frmt_val"] %>

方法

-

36

+

<%= @complexity["msr"][4]["frmt_val"] %>

贡献统计
@@ -145,4 +114,3 @@
- \ No newline at end of file diff --git a/app/views/quality_analysis/index.html.erb b/app/views/quality_analysis/index.html.erb index 3ce1a8e4a..e8fd5f8e2 100644 --- a/app/views/quality_analysis/index.html.erb +++ b/app/views/quality_analysis/index.html.erb @@ -1,7 +1,7 @@ <% if @name_flag %> <%= @results.each do |result| %>

- <%=link_to result["k"], project_quality_analysis_path(:name => result["k"]) %> + <%=link_to result["k"], project_quality_analysis_path(:resource_id => result["id"]) %>

<% end %> <% else %> diff --git a/app/views/repositories/_quality_analysis.html.erb b/app/views/repositories/_quality_analysis.html.erb index bf1b9ea41..7f6ab7ea1 100644 --- a/app/views/repositories/_quality_analysis.html.erb +++ b/app/views/repositories/_quality_analysis.html.erb @@ -1,7 +1,6 @@ -
-
代码质量分析
-
- <%= form_tag( url_for(:controller => 'quality_analysis', :action => 'create', :project_id => @project.id, :user_id => User.current.id, :identifier => @repository.identifier), :remote => true, :id => 'quality_analyses_form') do %> +
代码质量分析
+
+ <%= form_tag( url_for(:controller => 'quality_analysis', :action => 'create', :project_id => @project.id, :user_id => User.current.id, :identifier => @repository.identifier), :remote => true, :id => 'quality_analyses_form') do %>
@@ -20,6 +19,5 @@
- <% end %> -
-
\ No newline at end of file + <% end %> +
diff --git a/app/views/repositories/quality_analysis.js.erb b/app/views/repositories/quality_analysis.js.erb index c9427c246..eff2825f6 100644 --- a/app/views/repositories/quality_analysis.js.erb +++ b/app/views/repositories/quality_analysis.js.erb @@ -2,7 +2,7 @@ $('#ajax-modal').html('<%= escape_javascript( render :partial => 'repositories/q showModal('ajax-modal', '615px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before(""); -$('#ajax-modal').parent().css("top","20%").css("left","42%").css("border","3px solid #269ac9"); +$('#ajax-modal').parent().css("top","20%").css("left","30%").css("border","3px solid #269ac9"); $('#ajax-modal').parent().addClass("popbox_polls");