diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb
index 152335dd8..45d5a0ebf 100644
--- a/app/controllers/quality_analysis_controller.rb
+++ b/app/controllers/quality_analysis_controller.rb
@@ -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]
diff --git a/app/models/quality_analysis.rb b/app/models/quality_analysis.rb
index 09803467e..40a0d82e9 100644
--- a/app/models/quality_analysis.rb
+++ b/app/models/quality_analysis.rb
@@ -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
diff --git a/app/views/projects/_development_group.html.erb b/app/views/projects/_development_group.html.erb
index 2c7d36fb5..298416fd1 100644
--- a/app/views/projects/_development_group.html.erb
+++ b/app/views/projects/_development_group.html.erb
@@ -56,6 +56,10 @@
<% end %>
<% end %>
+
+
+ <%= link_to "zhiliangfenxi", project_quality_analysis_path(:project_id => @project.id), :class => "f14 c_blue02" %>
+
diff --git a/app/views/quality_analysis/_result_list.html.erb b/app/views/quality_analysis/_result_list.html.erb
index 4008bf6e5..a6e1f6431 100644
--- a/app/views/quality_analysis/_result_list.html.erb
+++ b/app/views/quality_analysis/_result_list.html.erb
@@ -1,16 +1,18 @@
-
-
-
分析结果
-
- <% @results.each do |result| %>
-
- - <%=link_to result["k"], project_quality_analysis_path(:resource_id => result["id"]), :class => "analysis-result-name fl fontBlue2" %>
- - 1.0
- - LOC
- - TECHNICAL DEBT
- - LAST ANALYSIS
-
-
- <% end %>
+
+
分析结果
+<% if @quality_analyses.count >0 %>
+ <% @quality_analyses.each do |qa| %>
+
+ - <%=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" %>
+ - 1.0
+ - <%= qa.branch %>
+ - <%= qa.language %>
+ - <<%= qa.author_login
+ %>/li>
+
+
+ <% end %>
+<% end %>
+
diff --git a/app/views/repositories/_quality_analysis.html.erb b/app/views/repositories/_quality_analysis.html.erb
index 7f6ab7ea1..f9726fb9b 100644
--- a/app/views/repositories/_quality_analysis.html.erb
+++ b/app/views/repositories/_quality_analysis.html.erb
@@ -12,7 +12,7 @@
- <%= 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" %>
diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb
index c639bcb6e..c096b732e 100644
--- a/app/views/repositories/show.html.erb
+++ b/app/views/repositories/show.html.erb
@@ -2,11 +2,13 @@
<%= render :partial => 'breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %>
ZIP下载
- <% 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 %>
<% if @entries.nil? %>
diff --git a/db/migrate/20160624054614_add_column_to_quality_analyses.rb b/db/migrate/20160624054614_add_column_to_quality_analyses.rb
new file mode 100644
index 000000000..ed3e6b137
--- /dev/null
+++ b/db/migrate/20160624054614_add_column_to_quality_analyses.rb
@@ -0,0 +1,6 @@
+class AddColumnToQualityAnalyses < ActiveRecord::Migration
+ def change
+ add_column :quality_analyses, :path, :string
+ add_column :quality_analyses, :branch, :string
+ end
+end
diff --git a/db/migrate/20160624055127_add_languae_to_quality_analyses.rb b/db/migrate/20160624055127_add_languae_to_quality_analyses.rb
new file mode 100644
index 000000000..de531b1db
--- /dev/null
+++ b/db/migrate/20160624055127_add_languae_to_quality_analyses.rb
@@ -0,0 +1,5 @@
+class AddLanguaeToQualityAnalyses < ActiveRecord::Migration
+ def change
+ add_column :quality_analyses, :language, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 01a001769..ee2da177b 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -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|