forked from Gitlink/forgeplus
update #477
|
|
@ -10,96 +10,111 @@ class Api::V1::Projects::CodeChecksController < Api::V1::BaseController
|
|||
render_ok({check:true})
|
||||
end
|
||||
def create
|
||||
@result = @client.create_task(params["branch"])
|
||||
render :index
|
||||
render_client do
|
||||
@result = @client.create_task(params["branch"])
|
||||
end
|
||||
end
|
||||
|
||||
def run_task
|
||||
@result = @client.run_task(params["branch"],params["task_id"])
|
||||
render :index
|
||||
render_client do
|
||||
@result = @client.run_task(params["branch"],params["task_id"])
|
||||
end
|
||||
end
|
||||
|
||||
def query_task
|
||||
@result = @client.query_task(params["task_id"])
|
||||
render_client do
|
||||
@result = @client.query_task(params["task_id"])
|
||||
end
|
||||
render :index
|
||||
end
|
||||
#----- 缺陷管理 ------
|
||||
def defects_summary
|
||||
allowed_query = %w[job_id merge_id]
|
||||
query_params, _ = filter_params(allowed_query_keys: allowed_query)
|
||||
@result = @client.defects_summary(query_params)
|
||||
render :index
|
||||
render_client do
|
||||
@result = @client.defects_summary(query_params)
|
||||
end
|
||||
end
|
||||
|
||||
def metrics_summary
|
||||
@result = @client.metrics_summary
|
||||
render :index
|
||||
render_client do
|
||||
@result = @client.metrics_summary
|
||||
end
|
||||
end
|
||||
|
||||
def defects_detail
|
||||
allowed_query = %w[offset limit status_ids severity delay_status]
|
||||
query_params, _ = filter_params(allowed_query_keys: allowed_query)
|
||||
Rails.logger.info "defects_detail controller "
|
||||
Rails.logger.info query_params
|
||||
@result = @client.defects_detail(query_params)
|
||||
render :index
|
||||
|
||||
render_client do
|
||||
@result = @client.defects_detail(query_params)
|
||||
end
|
||||
end
|
||||
|
||||
def defects_statistic
|
||||
@result = @client.defects_statistic
|
||||
render :index
|
||||
render_client do
|
||||
@result = @client.defects_statistic
|
||||
end
|
||||
end
|
||||
|
||||
def defect_status #put
|
||||
allowed_body = %w[defect_id defect_status]
|
||||
_, body_params = filter_params(allowed_body_keys: allowed_body)
|
||||
@result = @client.defect_status(body_params)
|
||||
render :index
|
||||
render_client do
|
||||
@result = @client.defect_status(body_params)
|
||||
end
|
||||
end
|
||||
#------ 代码问题 ----
|
||||
def issue_status #post
|
||||
allowed_body = %w[mergeId jobId status comment mergeKey operator]
|
||||
_, body_params = filter_params(allowed_body_keys: allowed_body)
|
||||
@result = @client.issue_status(body_params)
|
||||
render :index
|
||||
render_client do
|
||||
@result = @client.issue_status(body_params)
|
||||
end
|
||||
end
|
||||
|
||||
def issue_list_by_filter #post
|
||||
allowed_body = %w[mergeId jobId pageSize page languages ruleIds authors isNew statusIds severities delayStatus fileNames userTags cwes]
|
||||
_, body_params = filter_params(allowed_body_keys: allowed_body)
|
||||
@result = @client.issue_list_by_filter(body_params)
|
||||
render :index
|
||||
render_client do
|
||||
@result = @client.issue_list_by_filter(body_params)
|
||||
end
|
||||
end
|
||||
|
||||
def issue_filter #post
|
||||
allowed_body = %w[mergeId jobId facets languages ruleIds authors isNew statusIds severities delayStatus fileNames userTags cwes]
|
||||
_, body_params = filter_params(allowed_body_keys: allowed_body)
|
||||
@result = @client.issue_filter(body_params)
|
||||
render :index
|
||||
render_client do
|
||||
@result = @client.issue_filter(body_params)
|
||||
end
|
||||
end
|
||||
|
||||
def defect_metric_trend #get
|
||||
allowed_query = %w[start_date end_date dimension]
|
||||
query_params, _ = filter_params(allowed_query_keys: allowed_query)
|
||||
@result = @client.defect_metric_trend(query_params)
|
||||
render :index
|
||||
render_client do
|
||||
@result = @client.defect_metric_trend(query_params)
|
||||
end
|
||||
end
|
||||
|
||||
def criterion_rule
|
||||
allowed_query = %w[criterion_rule_id]
|
||||
query_params, _ = filter_params(allowed_query_keys: allowed_query)
|
||||
@result = @client.criterion_rule(query_params)
|
||||
render :index
|
||||
render_client do
|
||||
@result = @client.criterion_rule(query_params)
|
||||
end
|
||||
end
|
||||
|
||||
def generate_pdf
|
||||
@result = @client.generate_pdf
|
||||
render :index
|
||||
render_client do
|
||||
@result = @client.generate_pdf
|
||||
end
|
||||
end
|
||||
|
||||
def query_generate_pdf
|
||||
@result = @client.query_generate_pdf(params[:async_job_id])
|
||||
render :index
|
||||
render_client do
|
||||
@result = @client.query_generate_pdf(params[:async_job_id])
|
||||
end
|
||||
end
|
||||
|
||||
def download_pdf
|
||||
|
|
@ -117,22 +132,25 @@ class Api::V1::Projects::CodeChecksController < Api::V1::BaseController
|
|||
def measure_total
|
||||
allowed_body = %w[jobId search]
|
||||
_, body_params = filter_params(allowed_body_keys: allowed_body)
|
||||
@result = @client.measure_total(body_params)
|
||||
render :index
|
||||
render_client do
|
||||
@result = @client.measure_total(body_params)
|
||||
end
|
||||
end
|
||||
|
||||
def related_duplicate_blocks
|
||||
allowed_query = %w[job_id file_path block_id duplication_type]
|
||||
query_params, _ = filter_params(allowed_query_keys: allowed_query)
|
||||
@result = @client.related_duplicate_blocks(query_params)
|
||||
render :index
|
||||
render_client do
|
||||
@result = @client.related_duplicate_blocks(query_params)
|
||||
end
|
||||
end
|
||||
|
||||
def measure_list
|
||||
allowed_body = %w[filterType page pageSize]
|
||||
_, body_params = filter_params(allowed_body_keys: allowed_body)
|
||||
@result = @client.measure_list(body_params)
|
||||
render :index
|
||||
render_client do
|
||||
@result = @client.measure_list(body_params)
|
||||
end
|
||||
end
|
||||
private
|
||||
|
||||
|
|
@ -143,4 +161,12 @@ class Api::V1::Projects::CodeChecksController < Api::V1::BaseController
|
|||
[query_params, body_params]
|
||||
end
|
||||
|
||||
def render_client
|
||||
@code, @result = yield # 执行传入的 block
|
||||
if @code == "200"
|
||||
render :index
|
||||
else
|
||||
render_error(@result["error_msg"] + @result["error_code"])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -231,9 +231,15 @@ module HuaweiCloud
|
|||
end
|
||||
response = http.request(request)
|
||||
begin
|
||||
JSON.parse(response.body)
|
||||
result = JSON.parse(response.body)
|
||||
response_code = if result["error_code"].blank?
|
||||
response.code
|
||||
else
|
||||
"400"
|
||||
end
|
||||
[response_code, result]
|
||||
rescue JSON::ParserError, TypeError
|
||||
response.body
|
||||
[response.code, response.body]
|
||||
end
|
||||
|
||||
rescue => e
|
||||
|
|
|
|||
Loading…
Reference in New Issue