index for sonar result
This commit is contained in:
parent
128f6721be
commit
06fe02890f
|
@ -25,8 +25,8 @@ class QualityAnalysisController < ApplicationController
|
|||
language = params[:language]
|
||||
path = params[:path]
|
||||
identifier = params[:identifier]
|
||||
qa = QualityAnalysis.where(:project_id => @project.id).first
|
||||
version = qa.sonar_version + 1
|
||||
qa = QualityAnalysis.where(:project_id => @project.id, :author_login => user_name).first
|
||||
version = qa.nil? ? 1 : qa.sonar_version + 1
|
||||
properties = "sonar.projectKey=#{user_name}:#{identifier}
|
||||
sonar.projectName=#{user_name}:#{identifier}
|
||||
sonar.projectVersion=#{version}
|
||||
|
@ -47,9 +47,9 @@ class QualityAnalysisController < ApplicationController
|
|||
# genkins address
|
||||
@g.add_project_hook(@project.gpid, (jenkins_address + "/project/#{user_name}_#{identifier}"))
|
||||
if qa.nil?
|
||||
QualityAnalysis.create(:project_id => @project.id, :author_login => user_name, :rep_identifier => identifier, :version => version)
|
||||
QualityAnalysis.create(:project_id => @project.id, :author_login => user_name, :rep_identifier => identifier, :sonar_version => version, :path => path, :branch => branch, :language => language)
|
||||
else
|
||||
qa.update_attribute(:version, version)
|
||||
qa.update_attribute(:sonar_version, version)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -57,8 +57,9 @@ class QualityAnalysisController < ApplicationController
|
|||
@sonar_address = Redmine::Configuration['sonar_address']
|
||||
if params[:resource_id].nil?
|
||||
@name_flag = true
|
||||
projects_date = open(sonar_address + "/api/projects/index").read
|
||||
@results = JSON.parse(projects_date)
|
||||
@quality_analyses = QualityAnalysis.where(:project_id => @project.id)
|
||||
# projects_date = open(@sonar_address + "/api/projects/index").read
|
||||
# @results = JSON.parse(projects_date)
|
||||
else
|
||||
@name_flag = false
|
||||
@resource_id = params[:resource_id]
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
class QualityAnalysis < ActiveRecord::Base
|
||||
attr_accessible :author_login, :project_id, :rep_identifier, :sonar_version
|
||||
attr_accessible :author_login, :project_id, :rep_identifier, :sonar_version, :branch, :path, :rep_identifier
|
||||
end
|
||||
|
|
|
@ -56,6 +56,10 @@
|
|||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<!--quality_analysis-->
|
||||
<div class="subNav">
|
||||
<%= link_to "zhiliangfenxi", project_quality_analysis_path(:project_id => @project.id), :class => "f14 c_blue02" %>
|
||||
</div>
|
||||
<!-- more -->
|
||||
<div class="subNav subNav_jiantou" id="expand_tools_expand"><%= l(:label_project_more) %></div>
|
||||
<ul class="navContent" id="navContent">
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
<div style="min-height: 687px;" id="RSide" class="fl">
|
||||
<div class="project_r_h">
|
||||
<h2 class="project_h2">分析结果</h2>
|
||||
</div>
|
||||
<% @results.each do |result| %>
|
||||
<ul class="analysis-result-list">
|
||||
<li title="Name"><%=link_to result["k"], project_quality_analysis_path(:resource_id => result["id"]), :class => "analysis-result-name fl fontBlue2" %></li>
|
||||
<li class="analysis-result-version fl fontBlue2" title="Version">1.0</li>
|
||||
<li class="analysis-result-loc fl fontBlue2" title="Non Commenting Lines of Code">LOC</li>
|
||||
<li class="analysis-result-debt fl fontBlue2" title="Total effort (in days) to fix all the issues on the component and therefore to comply to all the requirements.">TECHNICAL DEBT</li>
|
||||
<li class="analysis-result-time fl fontBlue2" title="Last Analysis">LAST ANALYSIS</li>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
<% end %>
|
||||
<div class="project_r_h">
|
||||
<h2 class="project_h2">分析结果</h2>
|
||||
</div>
|
||||
<% if @quality_analyses.count >0 %>
|
||||
<% @quality_analyses.each do |qa| %>
|
||||
<ul class="analysis-result-list">
|
||||
<li title="Name"><%=link_to "#{qa.author_login}:#{qa.rep_identifier}", project_quality_analysis_path(:resource_id => qa.author_login+":"+qa.rep_identifier), :class => "analysis-result-name fl fontBlue2" %></li>
|
||||
<li class="analysis-result-version fl fontBlue2" title="Version">1.0</li>
|
||||
<li class="analysis-result-loc fl fontBlue2" title="branch"><%= qa.branch %></li>
|
||||
<li class="analysis-result-debt fl fontBlue2" title="Language"><%= qa.language %></li>
|
||||
<li class="analysis-result-time fl fontBlue2" title="User"><<%= qa.author_login
|
||||
%>/li>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
</div>
|
||||
<div class="mb10">
|
||||
<div>
|
||||
<%= select_tag :language, options_for_select(["Java","C","PHP", "Web"]), :id => 'branch', :class => "analysis-option-box" %>
|
||||
<%= select_tag :language, options_for_select(["java","python","ruby","c++","c#", "Web"]), :id => 'branch', :class => "analysis-option-box" %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="courseSendSubmit mr15"><a href="javascript:void(0);" class="sendSourceText" onclick="$('#quality_analyses_form').submit();hideModal()">提交</a></div>
|
||||
|
|
|
@ -2,11 +2,13 @@
|
|||
<div class="project_r_h">
|
||||
<div class="fl"><h2 class="project_h2_repository"><%= render :partial => 'breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %></h2></div>
|
||||
<a href="<%= @zip_path %>" class="btn_zipdown fr" onclick="">ZIP下载</a>
|
||||
<% if is_project_manager?(User.current, @project.id) && QualityAnalysis.where(:project_id => @project.id).first.nil? %>
|
||||
<%# if is_project_manager?(User.current, @project.id) && QualityAnalysis.where(:project_id => @project.id).first.nil? %>
|
||||
<% if User.current.member_of?(@project) %>
|
||||
<%= link_to "质量分析", quality_analysis_path(:id => @project.id, :repository_id => @repository.identifier), :remote => true, :class => "btn_zipdown fr" %>
|
||||
<% else %>
|
||||
<%= link_to "质量分析", project_quality_analysis_path(:project_id => @project.id), :class => "btn_zipdown fr" %>
|
||||
<% end %>
|
||||
<%# else %>
|
||||
<%#= link_to "质量分析", project_quality_analysis_path(:project_id => @project.id), :class => "btn_zipdown fr" %>
|
||||
<%# end %>
|
||||
</div>
|
||||
<div class="repository_con" style="line-height:1.9;">
|
||||
<% if @entries.nil? %>
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
class AddColumnToQualityAnalyses < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :quality_analyses, :path, :string
|
||||
add_column :quality_analyses, :branch, :string
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddLanguaeToQualityAnalyses < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :quality_analyses, :language, :string
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20160622074138) do
|
||||
ActiveRecord::Schema.define(:version => 20160624055127) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -1841,6 +1841,9 @@ ActiveRecord::Schema.define(:version => 20160622074138) do
|
|||
t.datetime "updated_at", :null => false
|
||||
t.float "version", :default => 0.0
|
||||
t.integer "sonar_version", :default => 1
|
||||
t.string "path"
|
||||
t.string "branch"
|
||||
t.string "language"
|
||||
end
|
||||
|
||||
create_table "queries", :force => true do |t|
|
||||
|
|
Loading…
Reference in New Issue