From b4da913f2b32853868594d6da3e00224fe038216 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 21 Apr 2025 16:53:33 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20=E7=BB=84=E7=BB=87=E6=B5=81=E6=B0=B4?= =?UTF-8?q?=E7=BA=BF=E6=8C=89=E4=BB=93=E5=BA=93=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/pm/pipelines_controller.rb | 3 ++- app/views/api/pm/pipelines/index.json.jbuilder | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/pm/pipelines_controller.rb b/app/controllers/api/pm/pipelines_controller.rb index a69e3ac81..3ddfa350b 100644 --- a/app/controllers/api/pm/pipelines_controller.rb +++ b/app/controllers/api/pm/pipelines_controller.rb @@ -67,7 +67,8 @@ class Api::Pm::PipelinesController < Api::Pm::BaseController end # Rails.logger.info("@run_result======#{@run_result}") @disabled_workflows = Gitea::RepoUnit.where(repo_id: project_gpids, type: 10).where("config is not null") - @pipelines = Action::Pipeline.where(project_id: @project_ids).order(updated_at: :desc) + @pipelines = Action::Pipeline.select("distinct project_id,max(updated_at) as updated_at") + .where(project_id: @project_ids).group(:project_id).order(updated_at: :desc) @pipelines = @pipelines.where("pipeline_name like ?", "%#{params[:pipeline_name]}%") if params[:pipeline_name].present? @pipelines = @pipelines.where(pipeline_type: params[:pipeline_type]) if params[:pipeline_type].present? @pipelines = kaminari_paginate(@pipelines) diff --git a/app/views/api/pm/pipelines/index.json.jbuilder b/app/views/api/pm/pipelines/index.json.jbuilder index 7ae7abd40..9322ae210 100644 --- a/app/views/api/pm/pipelines/index.json.jbuilder +++ b/app/views/api/pm/pipelines/index.json.jbuilder @@ -9,7 +9,8 @@ json.projects @pipelines.map(&:project_id).uniq.each do |project_id| json.identifier project.identifier json.name project.name json.url "#{Rails.application.config_for(:configuration)['platform_url']}/#{project.owner.name}/#{project.identifier}" - json.pipelines @pipelines.select { |p| p.project_id == project_id }.each do |pipeline| + json.pipelines @pipelines.select { |p| p.project_id == project_id }.each do |id| + pipeline = Action::Pipeline.find_by(id: id) json.extract! pipeline, :id, :project_id, :pipeline_name, :pipeline_status, :description, :file_name, :is_graphic_design, :repo_name, :repo_identifier, :branch, :event, :sha, :disable, :json, :yaml, :created_at, :updated_at repo_config = @disabled_workflows.select { |config| config.repo_id = pipeline.project.gpid }