fixed 组织流水线运行数据判断是否有文件存在
This commit is contained in:
parent
88415e256d
commit
7ff07e9c29
|
@ -1,9 +1,12 @@
|
|||
class Api::V1::Projects::Actions::RunsController < Api::V1::Projects::Actions::BaseController
|
||||
|
||||
def index
|
||||
@files = $gitea_client.get_repos_contents_by_owner_repo_filepath(@project&.owner&.login, @project&.identifier, ".gitea/workflows/#{params[:workflow]}") rescue []
|
||||
@has_file = @files.select { |i| i['name'] == params[:workflow] }.present?
|
||||
if @has_file
|
||||
@result_object = Api::V1::Projects::Actions::Runs::ListService.call(@project, {workflow: params[:workflow], page: page, limit: limit}, current_user&.gitea_token)
|
||||
@begin_num = (page.to_i - 1) * limit.to_i
|
||||
# puts @result_object
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
if @has_file
|
||||
json.total_data @result_object[:total_data].to_i
|
||||
if @result_object[:data]["Runs"].present?
|
||||
json.runs @result_object[:data]["Runs"].each_with_index.to_a do |run, index|
|
||||
|
@ -22,3 +23,7 @@ if @result_object[:data]["Runs"].present?
|
|||
else
|
||||
json.runs []
|
||||
end
|
||||
else
|
||||
json.total_data 0
|
||||
json.runs []
|
||||
end
|
Loading…
Reference in New Issue