fix: remove project tasks_count

This commit is contained in:
yystopf 2022-05-13 13:53:25 +08:00
parent 3d9fe5bba5
commit 7fcbbb7922
2 changed files with 6 additions and 6 deletions

View File

@ -7,13 +7,13 @@ class Traces::ProjectsController < Traces::BaseController
def tasks def tasks
branch_name = params[:branch_name] branch_name = params[:branch_name]
return render_error("无可用检测次数") if @project&.trace_tasks_count >= 5 # return render_error("无可用检测次数") if @project&.trace_tasks_count >= 5
return render_error("分支名不能为空!") if branch_name.blank? return render_error("分支名不能为空!") if branch_name.blank?
@all_branches = Gitea::Repository::Branches::ListNameService.call(@project&.owner, @project.identifier) @all_branches = Gitea::Repository::Branches::ListNameService.call(@project&.owner, @project.identifier)
return render_error("请输入正确的分支名!") unless @all_branches["branch_name"].include?(branch_name) return render_error("请输入正确的分支名!") unless @all_branches["branch_name"].include?(branch_name)
code, data, error = Trace::CheckService.call(current_user.trace_token, @project, "1", branch_name) code, data, error = Trace::CheckService.call(current_user.trace_token, @project, "1", branch_name)
if code == 200 if code == 200
@project.increment!(:trace_tasks_count, 1) # @project.increment!(:trace_tasks_count, 1)
render_ok render_ok
else else
render_error("检测失败 Error:#{error}") render_error("检测失败 Error:#{error}")
@ -43,7 +43,7 @@ class Traces::ProjectsController < Traces::BaseController
return render_error("project_id错误") if params[:project_id].blank? return render_error("project_id错误") if params[:project_id].blank?
code, data, error = Trace::ReloadCheckService.call(current_user.trace_token, params[:project_id]) code, data, error = Trace::ReloadCheckService.call(current_user.trace_token, params[:project_id])
if code == 200 if code == 200
@project.increment!(:trace_tasks_count, 1) # @project.increment!(:trace_tasks_count, 1)
render_ok render_ok
else else
render_error("重新检测失败 Error:#{error}") render_error("重新检测失败 Error:#{error}")

View File

@ -12,11 +12,11 @@ class Trace::PdfReportService < Trace::ClientService
end end
def call def call
content = URI.open("#{domain}#{base_url}#{url}?task_id#{task_id}", "Authorization" => token) content = open("#{domain}#{base_url}#{url}?task_id=#{task_id}", "Authorization" => token)
if content.is_a?(Tempfile) if content.is_a?(Tempfile)
check_file_path check_file_path
IO.copy_stream(content, "#{save_path}/#{task_id}.zip") IO.copy_stream(content, "#{save_path}/#{task_id}.pdf")
return {code: 200, download_url: "/trace_task_results/#{task_id}.zip"} return {code: 200, download_url: "/trace_task_results/#{task_id}.pdf"}
else else
return {code: 404} return {code: 404}
end end