fixed: 流水线批量查询运行数据,改成一维数据方便使用,status

This commit is contained in:
xxq250 2025-01-24 08:32:53 +08:00
parent 5d01e8ae40
commit 2e7e25e2d1
2 changed files with 4 additions and 4 deletions

View File

@ -2,11 +2,11 @@ class Api::Pm::ActionRunsController < Api::Pm::BaseController
before_action :require_login
def index
render_error('请输入workflows') if params[:workflows].blank?
tip_exception('请输入workflows') if params[:workflows].blank?
@owner = Owner.find_by(login: params[:owner_id].to_s) || Owner.find_by(id: params[:owner_id].to_s)
render_error('组织未找到') if @owner.blank?
tip_exception('组织未找到') if @owner.blank?
action_runs = Gitea::ActionRun.where(owner_id: @owner.gitea_uid)
group_data = action_runs.where(workflow_id: params[:workflows].to_s.split(",")).group(:workflow_id, :status).count
group_data = action_runs.where(workflow_id: params[:workflows].to_s.split(",")).where(status: [1,2]).group(:workflow_id, :status).count
@result = []
params[:workflows].to_s.split(",").each do |file|
last_action_run = action_runs.where(workflow_id: file).order(updated: :desc).first

View File

@ -5,7 +5,7 @@ class Api::V1::Projects::Actions::ActionsController < Api::V1::Projects::Actions
@action_runs = Gitea::ActionRun.where(repo_id: @project.gpid)
@action_runs = @action_runs.where(id: params[:ids].split(",")) if params[:ids].present?
@action_runs = @action_runs.where(workflow_id: params[:workflow_ids].split(",")) if params[:workflow_ids].present?
group_data = @action_runs.group(:workflow_id, :status).count
group_data = @action_runs.where(status: [1,2]).group(:workflow_id, :status).count
@result = []
@files.map{|i|i['name']}.each do |file|
last_action_run = @action_runs.where(workflow_id: file).order(updated: :desc).first