get data from sonar API
This commit is contained in:
parent
2275fe6d23
commit
ce6e6116b5
|
@ -8,7 +8,7 @@ class QualityAnalysisController < ApplicationController
|
|||
require 'json'
|
||||
require 'open-uri'
|
||||
|
||||
def new
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
|
@ -24,9 +24,11 @@ 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
|
||||
properties = "sonar.projectKey=#{user_name}:#{identifier}
|
||||
sonar.projectName=#{user_name}:#{identifier}
|
||||
sonar.projectVersion=1.0
|
||||
sonar.projectVersion=#{version}
|
||||
sonar.sources=#{path}
|
||||
sonar.language=#{language.downcase}
|
||||
sonar.sourceEncoding=utf-8"
|
||||
|
@ -43,13 +45,24 @@ class QualityAnalysisController < ApplicationController
|
|||
# relace gitlab hook
|
||||
# genkins address
|
||||
@g.add_project_hook(@project.gpid,"http://123.59.135.93:8890/project/#{user_name}_#{identifier}")
|
||||
QualityAnalysis.create(:project_id => @project.id, :author_login => user_name, :rep_identifier => identifier)
|
||||
if qa.nil?
|
||||
QualityAnalysis.create(:project_id => @project.id, :author_login => user_name, :rep_identifier => identifier, :version => version)
|
||||
else
|
||||
qa.update_attribute(:version, version)
|
||||
end
|
||||
end
|
||||
|
||||
def index
|
||||
data = open('http://123.59.135.93:8891/api/resources/index?resource=my:project985&depth=-1&metrics=complexity,class_complexity,lines,comment_lines,blocker_violations').read
|
||||
@cc =JSON.parse(data)
|
||||
|
||||
if params[:name].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)
|
||||
end
|
||||
end
|
||||
|
||||
# Find project of id params[:project_id]
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
class QualityAnalysis < ActiveRecord::Base
|
||||
attr_accessible :author_login, :project_id, :rep_identifier
|
||||
attr_accessible :author_login, :project_id, :rep_identifier, :sonar_version
|
||||
end
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
class SonarAnalysis < ActiveRecord::Base
|
||||
attr_accessible :author_login, :project_id, :rep_identifier
|
||||
end
|
|
@ -1,3 +1,10 @@
|
|||
<% @cc.each do |c| %>
|
||||
<%= c %>
|
||||
<% end %>
|
||||
<% if @name_flag %>
|
||||
<%= @results.each do |result| %>
|
||||
<p>
|
||||
<%=link_to result["k"], project_quality_analysis_path(:name => result["k"]) %>
|
||||
</p>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= @cc %>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddJkVersionToQualityAnalysis < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :quality_analyses, :sonar_version, :integer, :default => false
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20160622015019) do
|
||||
ActiveRecord::Schema.define(:version => 20160622074138) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -1837,8 +1837,10 @@ ActiveRecord::Schema.define(:version => 20160622015019) do
|
|||
t.integer "project_id"
|
||||
t.string "author_login"
|
||||
t.string "rep_identifier"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.float "version", :default => 0.0
|
||||
t.integer "sonar_version", :default => 1
|
||||
end
|
||||
|
||||
create_table "queries", :force => true do |t|
|
||||
|
|
Loading…
Reference in New Issue