From 076d92a3ebbd730f42b2a70448a4aecedbadf49c Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 31 Mar 2025 20:47:23 +0800 Subject: [PATCH 01/45] =?UTF-8?q?fixed=20=E5=AF=86=E7=A0=81=E5=A4=84?= =?UTF-8?q?=E7=90=86=EF=BC=8C=E5=85=BC=E5=AE=B9base64?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/accounts_controller.rb | 10 +++++----- app/controllers/api/v1/users_controller.rb | 4 ++-- .../organizations/organizations_controller.rb | 2 +- app/forms/base_form.rb | 6 +++--- app/services/accounts/reset_password_service.rb | 4 ++-- app/services/api/v1/users/update_email_service.rb | 2 +- app/services/api/v1/users/update_phone_service.rb | 2 +- app/services/users/register_service.rb | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 119812225..5e4e22dbd 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -144,7 +144,7 @@ class AccountsController < ApplicationController user = Users::RegisterService.call(register_params) user.mail = "#{user.login}@example.org" if user.mail.blank? - password = decrypt(register_params[:password]) rescue "" + password = decrypt(register_params[:password]) rescue register_params[:password].to_s password = password.strip # gitea用户注册, email, username, password @@ -195,7 +195,7 @@ class AccountsController < ApplicationController # 用户登录 def login - password = decrypt(login_params[:password]) rescue "" + password = decrypt(login_params[:password]) rescue login_params[:password].to_s Users::LoginForm.new(login_params.merge!({password: password})).validate! @user = User.try_to_login(params[:login], password) @@ -225,9 +225,9 @@ class AccountsController < ApplicationController end def change_password - password = decrypt(params[:password]) rescue "" - new_password_repeat = decrypt(params[:new_password_repeat]) rescue "" - old_password = decrypt(params[:old_password]) rescue "" + password = decrypt(params[:password]) rescue params[:password].to_s + new_password_repeat = decrypt(params[:new_password_repeat]) rescue params[:new_password_repeat].to_s + old_password = decrypt(params[:old_password]) rescue params[:old_password] return render_error("两次输入的密码不一致") if password.to_s != new_password_repeat.to_s @user = User.find_by(login: params[:login]) return render_forbidden unless User.current.login == @user&.login diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index 676304917..44f74c261 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -54,7 +54,7 @@ class Api::V1::UsersController < Api::V1::BaseController end def check_password - password = decrypt(params[:password]) rescue "" + password = decrypt(params[:password]) rescue params[:password].to_s return tip_exception(-5, "8~16位密码,支持字母数字和符号") unless password =~ CustomRegexp::PASSWORD return tip_exception(-5, "密码错误") unless @observe_user.check_password?(password) render_ok @@ -127,7 +127,7 @@ class Api::V1::UsersController < Api::V1::BaseController def destroy - password = decrypt(params[:password]) rescue "" + password = decrypt(params[:password]) rescue params[:password].to_s return tip_exception(-1, "密码不正确.") unless @observe_user.check_password?(password) org_ids = TeamUser.where(user_id: @observe_user.id).pluck(:organization_id) | OrganizationUser.where(user_id: @observe_user.id).pluck(:organization_id) org_count = TeamUser.where(organization_id: org_ids).where(user_id: @observe_user.id).joins(:team).where(teams: {authorize: %w(owner)}).count diff --git a/app/controllers/organizations/organizations_controller.rb b/app/controllers/organizations/organizations_controller.rb index 6cedea496..f61320638 100644 --- a/app/controllers/organizations/organizations_controller.rb +++ b/app/controllers/organizations/organizations_controller.rb @@ -140,7 +140,7 @@ class Organizations::OrganizationsController < Organizations::BaseController end def password - decrypt(params[:password]) rescue "" + decrypt(params[:password]) rescue params[:password].to_s end def load_organization diff --git a/app/forms/base_form.rb b/app/forms/base_form.rb index eb00ec562..0b3969ee8 100644 --- a/app/forms/base_form.rb +++ b/app/forms/base_form.rb @@ -54,14 +54,14 @@ class BaseForm end def check_password(password) - password = decrypt(password) rescue "" + password = decrypt(password) rescue password password = strip(password) raise PasswordFormatError, "密码8~16位密码,支持字母数字和符号" unless password =~ CustomRegexp::PASSWORD end def check_password_confirmation(password, password_confirmation) - password = decrypt(password) rescue "" - password_confirmation = decrypt(password_confirmation) rescue "" + password = decrypt(password) rescue password + password_confirmation = decrypt(password_confirmation) rescue password_confirmation password = strip(password) password_confirmation = strip(password_confirmation) diff --git a/app/services/accounts/reset_password_service.rb b/app/services/accounts/reset_password_service.rb index 58d0fda8b..f05a2fe5c 100644 --- a/app/services/accounts/reset_password_service.rb +++ b/app/services/accounts/reset_password_service.rb @@ -4,8 +4,8 @@ module Accounts # login、code、password、password_confirmation def initialize(user, params) @user = user - @password = decrypt(params[:password]) rescue "" - @password_confirmation = decrypt(params[:password_confirmation]) rescue "" + @password = decrypt(params[:password]) rescue params[:password].to_s + @password_confirmation = decrypt(params[:password_confirmation]) rescue params[:password_confirmation].to_s end def call diff --git a/app/services/api/v1/users/update_email_service.rb b/app/services/api/v1/users/update_email_service.rb index 3f0875d8a..cd7f9b0ef 100644 --- a/app/services/api/v1/users/update_email_service.rb +++ b/app/services/api/v1/users/update_email_service.rb @@ -11,7 +11,7 @@ class Api::V1::Users::UpdateEmailService < ApplicationService def initialize(user, params, token =nil) @user = user @token = token - @password = decrypt(params[:password]) rescue "" + @password = decrypt(params[:password]) rescue params[:password].to_s @mail = params[:email] @old_mail = user.mail @code = params[:code] diff --git a/app/services/api/v1/users/update_phone_service.rb b/app/services/api/v1/users/update_phone_service.rb index b79387773..cb9b12258 100644 --- a/app/services/api/v1/users/update_phone_service.rb +++ b/app/services/api/v1/users/update_phone_service.rb @@ -9,7 +9,7 @@ class Api::V1::Users::UpdatePhoneService < ApplicationService def initialize(user, params) @user = user - @password = decrypt(params[:password]) rescue "" + @password = decrypt(params[:password]) rescue params[:password].to_s @phone = params[:phone] @code = params[:code] @verify_code = VerificationCode.where(phone: @phone, code_type: 4).last diff --git a/app/services/users/register_service.rb b/app/services/users/register_service.rb index f6c8c2cf2..296a26a02 100644 --- a/app/services/users/register_service.rb +++ b/app/services/users/register_service.rb @@ -4,7 +4,7 @@ class Users::RegisterService < ApplicationService def initialize(params) @login = params[:login] @namespace = params[:namespace] - @password = decrypt(params[:password]) rescue "" + @password = decrypt(params[:password]) rescue params[:password].to_s @code = params[:code] end From e70e8db02dba3de219eb0d27c1e8b0ccbbae4a65 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 1 Apr 2025 11:35:00 +0800 Subject: [PATCH 02/45] =?UTF-8?q?fixed=20remote=5Fregister=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=89=8B=E6=9C=BA=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/accounts_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 5e4e22dbd..bbca99f1b 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -32,11 +32,12 @@ class AccountsController < ApplicationController username = params[:username]&.gsub(/\s+/, "") tip_exception("无法使用以下关键词:#{username},请重新命名") if ReversedKeyword.check_exists?(username) email = params[:email]&.gsub(/\s+/, "") + phone = params[:phone]&.gsub(/\s+/, "") password = params[:password] platform = (params[:platform] || 'forge')&.gsub(/\s+/, "") ActiveRecord::Base.transaction do - result = autologin_register(username, email, password, platform) + result = autologin_register(username, email, password, platform, phone) if result[:message].blank? render_ok({user: result[:user]}) else From 1639f1d4346b5942a691befe8823399269b47c9a Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 1 Apr 2025 17:13:17 +0800 Subject: [PATCH 03/45] =?UTF-8?q?fixed=20home=20=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/home_controller.rb | 17 +++++++++++++++++ app/views/home/index.json.jbuilder | 26 +++++++------------------- 2 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 app/controllers/home_controller.rb diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb new file mode 100644 index 000000000..39e5750d0 --- /dev/null +++ b/app/controllers/home_controller.rb @@ -0,0 +1,17 @@ +class HomeController < ApplicationController + + def index + @user_count = Rails.cache.fetch("homecontroller:user_count", expires_in: 1.hours) do + User.count + end + @project_count = Rails.cache.fetch("homecontroller:project_count", expires_in: 1.hours) do + Project.count + end + @project_dataset_count = Rails.cache.fetch("homecontroller:project_dataset_count", expires_in: 1.hours) do + ProjectDataset.count + end + @commit_count = Rails.cache.fetch("homecontroller:commit_count", expires_in: 1.hours) do + CommitLog.count + end + end +end \ No newline at end of file diff --git a/app/views/home/index.json.jbuilder b/app/views/home/index.json.jbuilder index de219052f..3781de440 100644 --- a/app/views/home/index.json.jbuilder +++ b/app/views/home/index.json.jbuilder @@ -1,21 +1,9 @@ -json.images_url @images_url - -json.reps @rep_list - -json.shixuns do - json.partial! 'shixuns/shixun', locals: {shixuns: @shixuns} +json.status 0 +json.message "success" +json.statistics_data do + json.user_count @user_count + json.project_count @project_count + json.project_dataset_count @project_dataset_count + json.commit_count @commit_count end -json.subjects do - json.partial! 'subjects/subject', locals: {subjects: @subjects} -end - -# if current_laboratory.main_site? -# json.teachers do -# json.partial! 'users/user_small', users: @tea_users -# end -# -# json.students do -# json.partial! 'users/user_small', users: @stu_users -# end -# end From 5d804ddeb644d84f01fd34330e632ab505888dad Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 7 Apr 2025 10:03:14 +0800 Subject: [PATCH 04/45] =?UTF-8?q?fixed=20=E6=88=91=E7=9A=84=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E9=A1=B9=E4=BB=85=E6=98=BE=E7=A4=BA=E8=B4=9F=E8=B4=A3?= =?UTF-8?q?=E4=BA=BA=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/pm/dashboards_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/pm/dashboards_controller.rb b/app/controllers/api/pm/dashboards_controller.rb index 36e361079..574d084a1 100644 --- a/app/controllers/api/pm/dashboards_controller.rb +++ b/app/controllers/api/pm/dashboards_controller.rb @@ -19,7 +19,7 @@ class Api::Pm::DashboardsController < Api::Pm::BaseController pm_project_ids = params[:pm_project_ids].split(",") rescue [] pm_issue_types = params[:pm_issue_types].split(",") rescue [] @all_issues = Issue.where(pm_project_id: pm_project_ids, pm_issue_type: pm_issue_types) - @issues = @all_issues.joins(:issue_participants).where(issue_participants: {participant_id: current_user.id}) + @issues = @all_issues.joins(:issue_participants).where(issue_participants: {participant_id: current_user.id, participant_type: 'assigned'}) @issues = @issues.where.not(status_id: 5) if params[:category] == "opened" @issues = kaminari_paginate(@issues.distinct.pm_includes) From b46645fd2d76c35ef4ea4d7d4bc3066d7525b786 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 8 Apr 2025 09:32:35 +0800 Subject: [PATCH 05/45] =?UTF-8?q?fixed=20=E5=8F=82=E6=95=B0=E4=B8=8D?= =?UTF-8?q?=E4=BC=A0=E6=97=B6=E5=A4=84=E7=90=86pipeline=5Fname?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/pipelines_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/v1/projects/pipelines_controller.rb b/app/controllers/api/v1/projects/pipelines_controller.rb index 5aa62caab..726f8a5c5 100644 --- a/app/controllers/api/v1/projects/pipelines_controller.rb +++ b/app/controllers/api/v1/projects/pipelines_controller.rb @@ -96,7 +96,8 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController @pipeline.file_name = ".gitea/workflows/#{@pipeline.pipeline_name}.yml" @pipeline.branch = params[:branch] || @project.default_branch @pipeline.json = params[:pipeline_json].to_json if params[:pipeline_json].present? - pipeline_yaml = params[:pipeline_yaml].present? ? params[:pipeline_yaml] : build_pipeline_yaml_new(params[:pipeline_name], params[:pipeline_json]) + @pipeline.pipeline_name = params[:pipeline_name] if params[:pipeline_name].present? + pipeline_yaml = params[:pipeline_yaml].present? ? params[:pipeline_yaml] : build_pipeline_yaml_new(@pipeline.pipeline_name, params[:pipeline_json]) tip_exception("流水线yaml内空不能为空") if pipeline_yaml.blank? @pipeline.yaml = pipeline_yaml Rails.logger.info "pipeline_yaml base64=========================#{Base64.encode64(@pipeline.yaml).gsub(/\n/, '')}" @@ -106,7 +107,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController file = interactor.result @pipeline.pipeline_type = @pipeline.json.present? ? 2 : 1 @pipeline.save - render_ok({ pipeline_yaml: pipeline_yaml, pipeline_name: params[:pipeline_name], file_name: @pipeline.file_name, sha: sha.present? ? sha : file['content']['sha'] }) + render_ok({ pipeline_yaml: pipeline_yaml, pipeline_name: @pipeline.pipeline_name, file_name: @pipeline.file_name, sha: sha.present? ? sha : file['content']['sha'] }) end def build_yaml From 4d22889ba9023e1a1068e1dbf630af9acc5a8565 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 8 Apr 2025 09:55:03 +0800 Subject: [PATCH 06/45] fixed pipeline log --- app/controllers/api/v1/projects/pipelines_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/api/v1/projects/pipelines_controller.rb b/app/controllers/api/v1/projects/pipelines_controller.rb index 726f8a5c5..03cbc3765 100644 --- a/app/controllers/api/v1/projects/pipelines_controller.rb +++ b/app/controllers/api/v1/projects/pipelines_controller.rb @@ -102,6 +102,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController @pipeline.yaml = pipeline_yaml Rails.logger.info "pipeline_yaml base64=========================#{Base64.encode64(@pipeline.yaml).gsub(/\n/, '')}" sha = get_pipeline_file_sha(@pipeline.file_name, @pipeline.branch) + Rails.logger.info "content_params=========#{content_params("create")}" interactor = sha.present? ? Gitea::UpdateFileInteractor.call(current_user.gitea_token, @owner.login, content_params("update").merge(sha: sha)) : Gitea::CreateFileInteractor.call(current_user.gitea_token, @owner.login, content_params("create")) tip_exception(interactor.error) unless interactor.success? file = interactor.result From ef214af00a8921be77be4dbb14f42a3aded6f229 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 9 Apr 2025 08:42:19 +0800 Subject: [PATCH 07/45] =?UTF-8?q?fixed=20pipeline=20=E5=88=86=E6=94=AF?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=AF=BC=E8=87=B4=E4=BF=9D=E5=AD=98=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/pipelines_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/v1/projects/pipelines_controller.rb b/app/controllers/api/v1/projects/pipelines_controller.rb index 03cbc3765..f535b184c 100644 --- a/app/controllers/api/v1/projects/pipelines_controller.rb +++ b/app/controllers/api/v1/projects/pipelines_controller.rb @@ -94,15 +94,15 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController def save_yaml @pipeline = params[:id].present? ? Action::Pipeline.find(params[:id]) : Action::Pipeline.find_or_initialize_by(pipeline_name: params[:pipeline_name], project_id: @project.id) @pipeline.file_name = ".gitea/workflows/#{@pipeline.pipeline_name}.yml" - @pipeline.branch = params[:branch] || @project.default_branch + @pipeline.branch = params[:branch].to_json if params[:branch].present? @pipeline.json = params[:pipeline_json].to_json if params[:pipeline_json].present? @pipeline.pipeline_name = params[:pipeline_name] if params[:pipeline_name].present? pipeline_yaml = params[:pipeline_yaml].present? ? params[:pipeline_yaml] : build_pipeline_yaml_new(@pipeline.pipeline_name, params[:pipeline_json]) tip_exception("流水线yaml内空不能为空") if pipeline_yaml.blank? @pipeline.yaml = pipeline_yaml - Rails.logger.info "pipeline_yaml base64=========================#{Base64.encode64(@pipeline.yaml).gsub(/\n/, '')}" + #Rails.logger.info "pipeline_yaml base64=========================#{Base64.encode64(@pipeline.yaml).gsub(/\n/, '')}" sha = get_pipeline_file_sha(@pipeline.file_name, @pipeline.branch) - Rails.logger.info "content_params=========#{content_params("create")}" + #Rails.logger.info "content_params=========#{content_params("create")}" interactor = sha.present? ? Gitea::UpdateFileInteractor.call(current_user.gitea_token, @owner.login, content_params("update").merge(sha: sha)) : Gitea::CreateFileInteractor.call(current_user.gitea_token, @owner.login, content_params("create")) tip_exception(interactor.error) unless interactor.success? file = interactor.result From 15704c0a75aa8e174597ecc0ef2c6f80151808ce Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 9 Apr 2025 08:49:31 +0800 Subject: [PATCH 08/45] =?UTF-8?q?fixed=20=E9=A1=B9=E7=9B=AE=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=97=B6=E4=BF=AE=E6=AD=A3=E9=BB=98=E8=AE=A4=E5=88=86?= =?UTF-8?q?=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index d29d41ac0..f5130e30c 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -37,6 +37,10 @@ class RepositoriesController < ApplicationController @fork_project = Project.find_by(id: @project_fork_id) @fork_project_user = @fork_project.owner end + # 修正默认分支 + if @result[:repo].present? && @result[:repo]['default_branch'].present? && @result[:repo]['default_branch'] != @project.default_branch + @project.update_column('default_branch', @result[:repo]['default_branch']) + end rescue Exception => e uid_logger_error(e.message) tip_exception(e.message) From 6068d44d62a67c600117579e98b3739c9a123e62 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 9 Apr 2025 09:18:42 +0800 Subject: [PATCH 09/45] =?UTF-8?q?fixed=20=E5=90=8E=E5=8F=B0=E5=8D=A1?= =?UTF-8?q?=E7=89=87=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/admins/shared/_sidebar.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admins/shared/_sidebar.html.erb b/app/views/admins/shared/_sidebar.html.erb index d48db392d..0c9b9c495 100644 --- a/app/views/admins/shared/_sidebar.html.erb +++ b/app/views/admins/shared/_sidebar.html.erb @@ -51,7 +51,7 @@
  • <%= sidebar_item_group('#setting-index', '首页配置', icon: 'file', has_permission: current_user.admin? || current_user.business?) do %>
  • <%= sidebar_item(admins_topic_banners_path, 'banner管理', icon: 'image', controller: 'admins-topic-banners', has_permission: current_user.admin? || current_user.business?) %>
  • - +
  • <%= sidebar_item(admins_topic_cards_path, '卡片管理', icon: 'archive', controller: 'admins-topic-cards', has_permission: current_user.admin? || current_user.business?) %>
  • <%= sidebar_item(admins_topic_activity_forums_path, '平台动态管理', icon: 'bell', controller: 'admins-topic-activity_forums', has_permission: current_user.admin? || current_user.business?) %>
  • <%= sidebar_item(admins_topic_excellent_projects_path, '优秀仓库管理', icon: 'git', controller: 'admins-topic-excellent_projects', has_permission: current_user.admin? || current_user.business?) %>
  • <%= sidebar_item(admins_topic_pinned_forums_path, '精选文章管理', icon: 'edit', controller: 'admins-topic-pinned_forums', has_permission: current_user.admin? || current_user.business?) %>
  • From 137a67fe53bf7265f61601a0b151469a5bed8a81 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 9 Apr 2025 14:57:36 +0800 Subject: [PATCH 10/45] =?UTF-8?q?fixed=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=A6=81=E7=94=A8=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/pipelines_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v1/projects/pipelines_controller.rb b/app/controllers/api/v1/projects/pipelines_controller.rb index f535b184c..a428c4e03 100644 --- a/app/controllers/api/v1/projects/pipelines_controller.rb +++ b/app/controllers/api/v1/projects/pipelines_controller.rb @@ -8,6 +8,8 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController @action_runs = Gitea::ActionRun.where(repo_id: @project.gpid) group_data = @action_runs.where(status: [1,2]).group(:workflow_id, :status).count db_files = pipelines.pluck(:file_name) + disabled_config = Gitea::RepoUnit.where(repo_id: @project.gpid, type: 10)&.first&.config + @disabled_workflows = disabled_config.present? ? JSON.parse(disabled_config)["DisabledWorkflows"] : [] @run_result = [] @files.map { |i| i['name'] }.each do |file| unless db_files.include?(".gitea/workflows/#{file}") @@ -17,7 +19,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController file_name: ".gitea/workflows/#{file}", branch: @project.default_branch, is_graphic_design: false, - disable: disabled_workflows.include?(file.to_s), + disable: @disabled_workflows.include?(file.to_s), project_id: @project.id) interactor = Repositories::EntriesInteractor.call(@owner, @project.identifier, ".gitea/workflows/#{file}", ref: @project.default_branch) if interactor.success? From b4fd3b851edd2fecaae2712326910e603649e3e5 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 9 Apr 2025 14:58:24 +0800 Subject: [PATCH 11/45] =?UTF-8?q?fixed=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=A6=81=E7=94=A8=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/api/v1/projects/pipelines/index.json.jbuilder | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/api/v1/projects/pipelines/index.json.jbuilder b/app/views/api/v1/projects/pipelines/index.json.jbuilder index fb0a74393..81efa081a 100644 --- a/app/views/api/v1/projects/pipelines/index.json.jbuilder +++ b/app/views/api/v1/projects/pipelines/index.json.jbuilder @@ -4,6 +4,7 @@ json.message "success" json.pipelines @pipelines.each do |pipeline| json.extract! pipeline, :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 + json.disable @disabled_workflows.include?(pipeline.file_name.to_s.gsub(".gitea/workflows/", "")) json.pipeline_type pipeline.pipeline_type json.run_data @run_result.select { |result| result[:filename] == pipeline.file_name }.first end From 19783ac526705d2912d199d837a910a53fbbd13c Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 9 Apr 2025 15:03:14 +0800 Subject: [PATCH 12/45] =?UTF-8?q?fixed=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=A6=81=E7=94=A8=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/pipelines_controller.rb | 2 ++ app/views/api/v1/projects/pipelines/show.json.jbuilder | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v1/projects/pipelines_controller.rb b/app/controllers/api/v1/projects/pipelines_controller.rb index a428c4e03..915962e48 100644 --- a/app/controllers/api/v1/projects/pipelines_controller.rb +++ b/app/controllers/api/v1/projects/pipelines_controller.rb @@ -179,6 +179,8 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController def show @pipeline = Action::Pipeline.find_by(id: params[:id]) + disabled_config = Gitea::RepoUnit.where(repo_id: @project.gpid, type: 10)&.first&.config + @disabled_workflows = disabled_config.present? ? JSON.parse(disabled_config)["DisabledWorkflows"] : [] # @pipeline = Action::Pipeline.new(id: 0, pipeline_name: "test-ss", yaml: build_test_yaml) if @pipeline.blank? end diff --git a/app/views/api/v1/projects/pipelines/show.json.jbuilder b/app/views/api/v1/projects/pipelines/show.json.jbuilder index 996bd0556..b16932ba0 100644 --- a/app/views/api/v1/projects/pipelines/show.json.jbuilder +++ b/app/views/api/v1/projects/pipelines/show.json.jbuilder @@ -1,4 +1,5 @@ json.status 0 json.message "success" json.extract! @pipeline, :id, :pipeline_name, :pipeline_status, :description, :file_name, :is_graphic_design, :pipeline_type, - :repo_name, :repo_identifier, :branch, :event, :sha, :disable, :json, :yaml, :created_at, :updated_at + :repo_name, :repo_identifier, :branch, :event, :sha, :json, :yaml, :created_at, :updated_at +json.disable @disabled_workflows.include?(pipeline.file_name.to_s.gsub(".gitea/workflows/", "")) \ No newline at end of file From dbde8aad7cf6f83f5d514d0cd8feba126faa3f87 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 9 Apr 2025 15:04:31 +0800 Subject: [PATCH 13/45] =?UTF-8?q?fixed=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=A6=81=E7=94=A8=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/api/v1/projects/pipelines/show.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/api/v1/projects/pipelines/show.json.jbuilder b/app/views/api/v1/projects/pipelines/show.json.jbuilder index b16932ba0..258f0d706 100644 --- a/app/views/api/v1/projects/pipelines/show.json.jbuilder +++ b/app/views/api/v1/projects/pipelines/show.json.jbuilder @@ -2,4 +2,4 @@ json.status 0 json.message "success" json.extract! @pipeline, :id, :pipeline_name, :pipeline_status, :description, :file_name, :is_graphic_design, :pipeline_type, :repo_name, :repo_identifier, :branch, :event, :sha, :json, :yaml, :created_at, :updated_at -json.disable @disabled_workflows.include?(pipeline.file_name.to_s.gsub(".gitea/workflows/", "")) \ No newline at end of file +json.disable @disabled_workflows.include?(@pipeline.file_name.to_s.gsub(".gitea/workflows/", "")) \ No newline at end of file From 5fd5431d5cb84826a1ef58dd05044352195c1882 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 9 Apr 2025 15:11:21 +0800 Subject: [PATCH 14/45] =?UTF-8?q?fixed=20=E5=AF=BC=E5=85=A5=E7=9A=84?= =?UTF-8?q?=E6=B5=81=E6=B0=B4=E7=BA=BF=E7=BB=9F=E4=B8=80=E5=85=88=E7=A6=81?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/pipelines_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/v1/projects/pipelines_controller.rb b/app/controllers/api/v1/projects/pipelines_controller.rb index 915962e48..d8ec37083 100644 --- a/app/controllers/api/v1/projects/pipelines_controller.rb +++ b/app/controllers/api/v1/projects/pipelines_controller.rb @@ -13,13 +13,11 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController @run_result = [] @files.map { |i| i['name'] }.each do |file| unless db_files.include?(".gitea/workflows/#{file}") - disabled_config = Gitea::RepoUnit.where(repo_id: @project.gpid, type: 10)&.first&.config - disabled_workflows = disabled_config.present? ? JSON.parse(disabled_config)["DisabledWorkflows"] : [] pipeline = Action::Pipeline.new(pipeline_name: file.to_s.gsub(".yml", "").gsub(".yaml", ""), file_name: ".gitea/workflows/#{file}", branch: @project.default_branch, is_graphic_design: false, - disable: @disabled_workflows.include?(file.to_s), + disable: false, project_id: @project.id) interactor = Repositories::EntriesInteractor.call(@owner, @project.identifier, ".gitea/workflows/#{file}", ref: @project.default_branch) if interactor.success? @@ -27,6 +25,8 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController end pipeline.user_id = current_user.id pipeline.save + # 导入的流水线统一先禁用 + $gitea_hat_client.post_repos_actions_disable(@project&.owner&.login, @project&.identifier, {query: {workflow: file}}) rescue nil end last_action_run = @action_runs.where(workflow_id: file).order(updated: :desc).first last_action_run_json = last_action_run.present? ? { From 3236bb37b07a999c7330397546f3e2a3861e9f44 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 9 Apr 2025 15:13:13 +0800 Subject: [PATCH 15/45] =?UTF-8?q?fixed=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=A6=81=E7=94=A8=E7=8A=B6=E6=80=81=E6=9C=80=E5=90=8E=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/pipelines_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/v1/projects/pipelines_controller.rb b/app/controllers/api/v1/projects/pipelines_controller.rb index d8ec37083..74b433d5a 100644 --- a/app/controllers/api/v1/projects/pipelines_controller.rb +++ b/app/controllers/api/v1/projects/pipelines_controller.rb @@ -8,8 +8,6 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController @action_runs = Gitea::ActionRun.where(repo_id: @project.gpid) group_data = @action_runs.where(status: [1,2]).group(:workflow_id, :status).count db_files = pipelines.pluck(:file_name) - disabled_config = Gitea::RepoUnit.where(repo_id: @project.gpid, type: 10)&.first&.config - @disabled_workflows = disabled_config.present? ? JSON.parse(disabled_config)["DisabledWorkflows"] : [] @run_result = [] @files.map { |i| i['name'] }.each do |file| unless db_files.include?(".gitea/workflows/#{file}") @@ -58,6 +56,8 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController }.merge(last_action_run_json) end Rails.logger.info("@run_result======#{@run_result}") + disabled_config = Gitea::RepoUnit.where(repo_id: @project.gpid, type: 10)&.first&.config + @disabled_workflows = disabled_config.present? ? JSON.parse(disabled_config)["DisabledWorkflows"] : [] @pipelines = Action::Pipeline.where(project_id: @project.id).order(updated_at: :desc) @pipelines = paginate @pipelines end From d540dadb229ae1f134f69035402d3481b766bdcd Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 11 Apr 2025 11:19:23 +0800 Subject: [PATCH 16/45] =?UTF-8?q?fixed=20=E7=BB=84=E7=BB=87=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=E7=BA=BF=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/pm/pipelines_controller.rb | 71 +++++++++++++++++++ .../api/pm/pipelines/index.json.jbuilder | 15 ++++ config/routes/api.rb | 1 + 3 files changed, 87 insertions(+) create mode 100644 app/controllers/api/pm/pipelines_controller.rb create mode 100644 app/views/api/pm/pipelines/index.json.jbuilder diff --git a/app/controllers/api/pm/pipelines_controller.rb b/app/controllers/api/pm/pipelines_controller.rb new file mode 100644 index 000000000..00a85f948 --- /dev/null +++ b/app/controllers/api/pm/pipelines_controller.rb @@ -0,0 +1,71 @@ +class Api::Pm::PipelinesController < Api::Pm::BaseController + include RepositoriesHelper + before_action :require_operate_above, except: [:upload_results, :run_results] + + def index + @owner = Owner.find_by(login: params[:owner_id].to_s) || Owner.find_by(id: params[:owner_id].to_s) + tip_exception('组织未找到') if @owner.blank? + project_ids = @owner.projects.ids + project_gpids = @owner.projects.pluck(:gpid) + action_runs = Gitea::ActionRun.where(owner_id: @owner.gitea_uid) + group_data = action_runs.where(status: [1,2]).group(:workflow_id, :status).count + pipelines = Action::Pipeline.where(project_id: project_ids).order(updated_at: :desc) + run_files = Gitea::ActionRun.where(owner_id: @owner.gitea_uid).group(:workflow_id) + db_files = pipelines.pluck(:file_name) + @run_result = [] + run_files.each do |file_info| + file = file_info.workflow_id + project = Project.find_by(gpid: file.repo_id) + next if project.blank? + unless db_files.include?(".gitea/workflows/#{file}") + pipeline = Action::Pipeline.new(pipeline_name: file.to_s.gsub(".yml", "").gsub(".yaml", ""), + file_name: ".gitea/workflows/#{file}", + branch: project.default_branch, + is_graphic_design: false, + disable: false, + project_id: project.id) + interactor = Repositories::EntriesInteractor.call(@owner, project.identifier, ".gitea/workflows/#{file}", ref: project.default_branch) + if interactor.success? + pipeline.yaml = decode64_content(interactor.result, @owner, project.repository, project.default_branch, nil) + end + pipeline.user_id = current_user.id + pipeline.save + # 导入的流水线统一先禁用 + $gitea_hat_client.post_repos_actions_disable(project&.owner&.login, project&.identifier, {query: {workflow: file}}) rescue nil + end + last_action_run = action_runs.where(workflow_id: file).order(updated: :desc).first + last_action_run_json = last_action_run.present? ? { + id: last_action_run.id, + schedule: last_action_run.schedule_id > 0, + title: last_action_run.title, + index: last_action_run.index, + status: last_action_run.status, + started: last_action_run.started, + stopped: last_action_run.stopped, + length: last_action_run.stopped-last_action_run.started, + created: last_action_run.created, + updated: last_action_run.updated, + } : {} + + total = 0 + success = 0 + failure = 0 + group_data.each do |k,v| + total += v if k[0] == file + success += v if k[0] == file && k[1] == 1 + failure += v if k[0] == file && k[1] == 2 + end + @run_result << { + filename: ".gitea/workflows/#{file}", + total: total, + success: success, + failure: failure + }.merge(last_action_run_json) + 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.id).order(updated_at: :desc) + @pipelines = paginate @pipelines + end + +end diff --git a/app/views/api/pm/pipelines/index.json.jbuilder b/app/views/api/pm/pipelines/index.json.jbuilder new file mode 100644 index 000000000..1f9201334 --- /dev/null +++ b/app/views/api/pm/pipelines/index.json.jbuilder @@ -0,0 +1,15 @@ +json.status 0 +json.message "success" + +json.pipelines @pipelines.each do |pipeline| + json.extract! pipeline, :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 } + if repo_config.present? + json.disable JSON.parse(repo_config.first.config)["DisabledWorkflows"].to_s.include?(pipeline.file_name.to_s.gsub(".gitea/workflows/", "")) + else + json.disable pipeline.disable + end + json.pipeline_type pipeline.pipeline_type + json.run_data @run_result.select { |result| result[:filename] == pipeline.file_name }.first +end diff --git a/config/routes/api.rb b/config/routes/api.rb index 629ea93f7..be80bac3f 100644 --- a/config/routes/api.rb +++ b/config/routes/api.rb @@ -51,6 +51,7 @@ defaults format: :json do end end resources :action_runs, only: [:index] + resources :pipelines, only: [:index] end namespace :v1 do From b74d7c81664779582c8aed8b3c46f2ec983cdd82 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 11 Apr 2025 11:42:03 +0800 Subject: [PATCH 17/45] =?UTF-8?q?fixed=20=E7=BB=84=E7=BB=87=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=E7=BA=BF=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/pm/pipelines_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/pm/pipelines_controller.rb b/app/controllers/api/pm/pipelines_controller.rb index 00a85f948..e7fcb327c 100644 --- a/app/controllers/api/pm/pipelines_controller.rb +++ b/app/controllers/api/pm/pipelines_controller.rb @@ -15,7 +15,7 @@ class Api::Pm::PipelinesController < Api::Pm::BaseController @run_result = [] run_files.each do |file_info| file = file_info.workflow_id - project = Project.find_by(gpid: file.repo_id) + project = Project.find_by(gpid: file_info.repo_id) next if project.blank? unless db_files.include?(".gitea/workflows/#{file}") pipeline = Action::Pipeline.new(pipeline_name: file.to_s.gsub(".yml", "").gsub(".yaml", ""), From 1a21d548571d8fd8595b2c62ec72e95155dddaf3 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 11 Apr 2025 11:46:22 +0800 Subject: [PATCH 18/45] =?UTF-8?q?fixed=20=E7=BB=84=E7=BB=87=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=E7=BA=BF=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3,?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=86=85=E6=89=80=E6=9C=89=E4=BB=93=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/pm/pipelines_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/pm/pipelines_controller.rb b/app/controllers/api/pm/pipelines_controller.rb index e7fcb327c..04ad88d7f 100644 --- a/app/controllers/api/pm/pipelines_controller.rb +++ b/app/controllers/api/pm/pipelines_controller.rb @@ -64,7 +64,7 @@ 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.id).order(updated_at: :desc) + @pipelines = Action::Pipeline.where(project_id: project_ids).order(updated_at: :desc) @pipelines = paginate @pipelines end From 033c5cf19176554d150fcc77cc0386bbedbeaf48 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 17 Apr 2025 09:13:34 +0800 Subject: [PATCH 19/45] =?UTF-8?q?fixed=20=E7=BB=84=E7=BB=87=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=E7=BA=BF=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3,?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=86=85=E6=89=80=E6=9C=89=E4=BB=93=E5=BA=93?= =?UTF-8?q?,group=20by?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/pm/pipelines_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/pm/pipelines_controller.rb b/app/controllers/api/pm/pipelines_controller.rb index 04ad88d7f..af8f6d75d 100644 --- a/app/controllers/api/pm/pipelines_controller.rb +++ b/app/controllers/api/pm/pipelines_controller.rb @@ -10,7 +10,7 @@ class Api::Pm::PipelinesController < Api::Pm::BaseController action_runs = Gitea::ActionRun.where(owner_id: @owner.gitea_uid) group_data = action_runs.where(status: [1,2]).group(:workflow_id, :status).count pipelines = Action::Pipeline.where(project_id: project_ids).order(updated_at: :desc) - run_files = Gitea::ActionRun.where(owner_id: @owner.gitea_uid).group(:workflow_id) + run_files = Gitea::ActionRun.select(:workflow_id, :repo_id).where(owner_id: @owner.gitea_uid).group(:workflow_id, :repo_id) db_files = pipelines.pluck(:file_name) @run_result = [] run_files.each do |file_info| From aed452e144a5996100eccbce64943d2e1a51b821 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 17 Apr 2025 10:25:27 +0800 Subject: [PATCH 20/45] =?UTF-8?q?fixed=20=E7=BB=84=E7=BB=87=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=E7=BA=BF=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3,?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=86=85=E6=89=80=E6=9C=89=E4=BB=93=E5=BA=93?= =?UTF-8?q?,=E5=88=86=E7=BB=84=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/pm/pipelines_controller.rb | 5 +-- .../api/pm/pipelines/index.json.jbuilder | 31 ++++++++++++------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/app/controllers/api/pm/pipelines_controller.rb b/app/controllers/api/pm/pipelines_controller.rb index af8f6d75d..f6691e184 100644 --- a/app/controllers/api/pm/pipelines_controller.rb +++ b/app/controllers/api/pm/pipelines_controller.rb @@ -5,7 +5,7 @@ class Api::Pm::PipelinesController < Api::Pm::BaseController def index @owner = Owner.find_by(login: params[:owner_id].to_s) || Owner.find_by(id: params[:owner_id].to_s) tip_exception('组织未找到') if @owner.blank? - project_ids = @owner.projects.ids + @project_ids = @owner.projects.ids project_gpids = @owner.projects.pluck(:gpid) action_runs = Gitea::ActionRun.where(owner_id: @owner.gitea_uid) group_data = action_runs.where(status: [1,2]).group(:workflow_id, :status).count @@ -64,7 +64,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.where(project_id: @project_ids).order(updated_at: :desc) + @pipelines = @pipelines @pipelines = paginate @pipelines end diff --git a/app/views/api/pm/pipelines/index.json.jbuilder b/app/views/api/pm/pipelines/index.json.jbuilder index 1f9201334..60a71e880 100644 --- a/app/views/api/pm/pipelines/index.json.jbuilder +++ b/app/views/api/pm/pipelines/index.json.jbuilder @@ -1,15 +1,24 @@ json.status 0 json.message "success" - -json.pipelines @pipelines.each do |pipeline| - json.extract! pipeline, :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 } - if repo_config.present? - json.disable JSON.parse(repo_config.first.config)["DisabledWorkflows"].to_s.include?(pipeline.file_name.to_s.gsub(".gitea/workflows/", "")) - else - json.disable pipeline.disable +json.projects @project_ids.each do |project_id| + json.id project_id + project = Project.find_by(id: project_id) + if project.present? + json.owner project.owner.name + 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.repo_id == project_id }.each do |pipeline| + 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 } + if repo_config.present? + json.disable JSON.parse(repo_config.first.config)["DisabledWorkflows"].to_s.include?(pipeline.file_name.to_s.gsub(".gitea/workflows/", "")) + else + json.disable pipeline.disable + end + json.pipeline_type pipeline.pipeline_type + json.run_data @run_result.select { |result| result[:filename] == pipeline.file_name }.first + end end - json.pipeline_type pipeline.pipeline_type - json.run_data @run_result.select { |result| result[:filename] == pipeline.file_name }.first end From 4b93cab54ed4796be2c204e10329cb5dd23f4bc1 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 17 Apr 2025 10:26:51 +0800 Subject: [PATCH 21/45] =?UTF-8?q?fixed=20=E7=BB=84=E7=BB=87=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=E7=BA=BF=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3,?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=86=85=E6=89=80=E6=9C=89=E4=BB=93=E5=BA=93?= =?UTF-8?q?,=E5=88=86=E7=BB=84=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/pm/pipelines_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/pm/pipelines_controller.rb b/app/controllers/api/pm/pipelines_controller.rb index f6691e184..5a8a13420 100644 --- a/app/controllers/api/pm/pipelines_controller.rb +++ b/app/controllers/api/pm/pipelines_controller.rb @@ -9,7 +9,7 @@ class Api::Pm::PipelinesController < Api::Pm::BaseController project_gpids = @owner.projects.pluck(:gpid) action_runs = Gitea::ActionRun.where(owner_id: @owner.gitea_uid) group_data = action_runs.where(status: [1,2]).group(:workflow_id, :status).count - pipelines = Action::Pipeline.where(project_id: project_ids).order(updated_at: :desc) + pipelines = Action::Pipeline.where(project_id: @project_ids).order(updated_at: :desc) run_files = Gitea::ActionRun.select(:workflow_id, :repo_id).where(owner_id: @owner.gitea_uid).group(:workflow_id, :repo_id) db_files = pipelines.pluck(:file_name) @run_result = [] From c94111b3951a4cad4ec0781fbec720e64e059c1c Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 17 Apr 2025 10:28:49 +0800 Subject: [PATCH 22/45] =?UTF-8?q?fixed=20=E7=BB=84=E7=BB=87=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=E7=BA=BF=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3,?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=86=85=E6=89=80=E6=9C=89=E4=BB=93=E5=BA=93?= =?UTF-8?q?,=E5=88=86=E7=BB=84=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/api/pm/pipelines/index.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/api/pm/pipelines/index.json.jbuilder b/app/views/api/pm/pipelines/index.json.jbuilder index 60a71e880..975d36314 100644 --- a/app/views/api/pm/pipelines/index.json.jbuilder +++ b/app/views/api/pm/pipelines/index.json.jbuilder @@ -8,7 +8,7 @@ json.projects @project_ids.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.repo_id == project_id }.each do |pipeline| + json.pipelines @pipelines.select { |p| p.project_id == project_id }.each do |pipeline| 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 } From b494ed718bcf4442eba7afc43135bda30733fa2d Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 17 Apr 2025 10:33:31 +0800 Subject: [PATCH 23/45] =?UTF-8?q?fixed=20=E7=BB=84=E7=BB=87=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=E7=BA=BF=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3,?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=86=85=E6=89=80=E6=9C=89=E4=BB=93=E5=BA=93?= =?UTF-8?q?,=E5=88=86=E7=BB=84=E6=98=BE=E7=A4=BA=EF=BC=8C=E6=90=9C?= =?UTF-8?q?=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/pm/pipelines_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/api/pm/pipelines_controller.rb b/app/controllers/api/pm/pipelines_controller.rb index 5a8a13420..f85600ad7 100644 --- a/app/controllers/api/pm/pipelines_controller.rb +++ b/app/controllers/api/pm/pipelines_controller.rb @@ -65,6 +65,8 @@ class Api::Pm::PipelinesController < Api::Pm::BaseController 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 = @pipelines.where("pipeline_name like ?", "%#{param[:pipeline_name]}%") if param[:pipeline_name].present? + @pipelines = @pipelines.where(pipeline_type: param[:pipeline_type]) if param[:pipeline_type].present? @pipelines = @pipelines @pipelines = paginate @pipelines end From 68b08d8ca4cf85201b12f9779e33ec855d0f3d5b Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 17 Apr 2025 10:34:35 +0800 Subject: [PATCH 24/45] =?UTF-8?q?fixed=20=E7=BB=84=E7=BB=87=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=E7=BA=BF=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3,?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=86=85=E6=89=80=E6=9C=89=E4=BB=93=E5=BA=93?= =?UTF-8?q?,=E5=88=86=E7=BB=84=E6=98=BE=E7=A4=BA=EF=BC=8C=E6=90=9C?= =?UTF-8?q?=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/pm/pipelines_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/pm/pipelines_controller.rb b/app/controllers/api/pm/pipelines_controller.rb index f85600ad7..cafb43a4d 100644 --- a/app/controllers/api/pm/pipelines_controller.rb +++ b/app/controllers/api/pm/pipelines_controller.rb @@ -65,8 +65,8 @@ class Api::Pm::PipelinesController < Api::Pm::BaseController 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 = @pipelines.where("pipeline_name like ?", "%#{param[:pipeline_name]}%") if param[:pipeline_name].present? - @pipelines = @pipelines.where(pipeline_type: param[:pipeline_type]) if param[:pipeline_type].present? + @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 = @pipelines @pipelines = paginate @pipelines end From 4255966a5bcf893bee473a759004b1b23e814f00 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 17 Apr 2025 16:02:58 +0800 Subject: [PATCH 25/45] =?UTF-8?q?fixed=20=E7=AB=99=E5=86=85=E4=BF=A1?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users/messages_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/users/messages_controller.rb b/app/controllers/users/messages_controller.rb index 4feb4a98e..4d101a8f3 100644 --- a/app/controllers/users/messages_controller.rb +++ b/app/controllers/users/messages_controller.rb @@ -10,6 +10,8 @@ class Users::MessagesController < Users::BaseController result = Notice::Read::ListService.call(observed_user.id, message_type, message_status, page, limit) return render_error if result.nil? @data = result[2] + rescue + render_ok end def create From 2a0d4d6f45ce3427c50191dfa23d4c91446edf37 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 21 Apr 2025 12:02:01 +0800 Subject: [PATCH 26/45] =?UTF-8?q?fixed=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E6=9F=A5=E7=9C=8B=E7=BB=84=E7=BB=87=E7=9A=84?= =?UTF-8?q?=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/pm/pipelines_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/pm/pipelines_controller.rb b/app/controllers/api/pm/pipelines_controller.rb index cafb43a4d..f8f073c96 100644 --- a/app/controllers/api/pm/pipelines_controller.rb +++ b/app/controllers/api/pm/pipelines_controller.rb @@ -1,10 +1,12 @@ class Api::Pm::PipelinesController < Api::Pm::BaseController include RepositoriesHelper - before_action :require_operate_above, except: [:upload_results, :run_results] def index @owner = Owner.find_by(login: params[:owner_id].to_s) || Owner.find_by(id: params[:owner_id].to_s) tip_exception('组织未找到') if @owner.blank? + unless @owner.is_a?(Organization) && @owner.is_member?(current_user.id) + tip_exception('没有查看组织的权限') + end @project_ids = @owner.projects.ids project_gpids = @owner.projects.pluck(:gpid) action_runs = Gitea::ActionRun.where(owner_id: @owner.gitea_uid) From 0274456442aec20d9061326e342b4e9478251ab0 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 21 Apr 2025 12:06:02 +0800 Subject: [PATCH 27/45] =?UTF-8?q?fixed=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E5=8E=BB=E6=8E=89=E6=B2=A1=E6=9C=89=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=9A=84=E4=BB=93=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/pm/pipelines_controller.rb | 1 + app/views/api/pm/pipelines/index.json.jbuilder | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/pm/pipelines_controller.rb b/app/controllers/api/pm/pipelines_controller.rb index f8f073c96..fe94fd86f 100644 --- a/app/controllers/api/pm/pipelines_controller.rb +++ b/app/controllers/api/pm/pipelines_controller.rb @@ -69,6 +69,7 @@ class Api::Pm::PipelinesController < Api::Pm::BaseController @pipelines = Action::Pipeline.where(project_id: @project_ids).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? + @has_pipeline_ids = @pipelines.pluck(:project_id) @pipelines = @pipelines @pipelines = paginate @pipelines end diff --git a/app/views/api/pm/pipelines/index.json.jbuilder b/app/views/api/pm/pipelines/index.json.jbuilder index 975d36314..c7ee9e545 100644 --- a/app/views/api/pm/pipelines/index.json.jbuilder +++ b/app/views/api/pm/pipelines/index.json.jbuilder @@ -1,6 +1,6 @@ json.status 0 json.message "success" -json.projects @project_ids.each do |project_id| +json.projects @has_pipeline_ids.each do |project_id| json.id project_id project = Project.find_by(id: project_id) if project.present? From a8be844208bde1d11685d17db1e123ec3bce89c1 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 21 Apr 2025 12:07:37 +0800 Subject: [PATCH 28/45] =?UTF-8?q?fixed=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E5=8E=BB=E6=8E=89=E6=B2=A1=E6=9C=89=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=9A=84=E4=BB=93=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/pm/pipelines_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/pm/pipelines_controller.rb b/app/controllers/api/pm/pipelines_controller.rb index fe94fd86f..815dde10b 100644 --- a/app/controllers/api/pm/pipelines_controller.rb +++ b/app/controllers/api/pm/pipelines_controller.rb @@ -69,7 +69,7 @@ class Api::Pm::PipelinesController < Api::Pm::BaseController @pipelines = Action::Pipeline.where(project_id: @project_ids).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? - @has_pipeline_ids = @pipelines.pluck(:project_id) + @has_pipeline_ids = @pipelines.pluck(:project_id).uniq @pipelines = @pipelines @pipelines = paginate @pipelines end From bddfe9d8f747c289ef47fa063639b9d5f36477d2 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 21 Apr 2025 13:59:15 +0800 Subject: [PATCH 29/45] =?UTF-8?q?fixed=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/pm/pipelines_controller.rb | 3 +-- app/controllers/api/v1/projects/pipelines_controller.rb | 2 +- app/views/api/pm/pipelines/index.json.jbuilder | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/pm/pipelines_controller.rb b/app/controllers/api/pm/pipelines_controller.rb index 815dde10b..0d42a9749 100644 --- a/app/controllers/api/pm/pipelines_controller.rb +++ b/app/controllers/api/pm/pipelines_controller.rb @@ -20,7 +20,7 @@ class Api::Pm::PipelinesController < Api::Pm::BaseController project = Project.find_by(gpid: file_info.repo_id) next if project.blank? unless db_files.include?(".gitea/workflows/#{file}") - pipeline = Action::Pipeline.new(pipeline_name: file.to_s.gsub(".yml", "").gsub(".yaml", ""), + pipeline = Action::Pipeline.find_or_initialize_by(pipeline_name: file.to_s.gsub(".yml", "").gsub(".yaml", ""), file_name: ".gitea/workflows/#{file}", branch: project.default_branch, is_graphic_design: false, @@ -69,7 +69,6 @@ class Api::Pm::PipelinesController < Api::Pm::BaseController @pipelines = Action::Pipeline.where(project_id: @project_ids).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? - @has_pipeline_ids = @pipelines.pluck(:project_id).uniq @pipelines = @pipelines @pipelines = paginate @pipelines end diff --git a/app/controllers/api/v1/projects/pipelines_controller.rb b/app/controllers/api/v1/projects/pipelines_controller.rb index 74b433d5a..98045e08d 100644 --- a/app/controllers/api/v1/projects/pipelines_controller.rb +++ b/app/controllers/api/v1/projects/pipelines_controller.rb @@ -11,7 +11,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController @run_result = [] @files.map { |i| i['name'] }.each do |file| unless db_files.include?(".gitea/workflows/#{file}") - pipeline = Action::Pipeline.new(pipeline_name: file.to_s.gsub(".yml", "").gsub(".yaml", ""), + pipeline = Action::Pipeline.find_or_initialize_by(pipeline_name: file.to_s.gsub(".yml", "").gsub(".yaml", ""), file_name: ".gitea/workflows/#{file}", branch: @project.default_branch, is_graphic_design: false, diff --git a/app/views/api/pm/pipelines/index.json.jbuilder b/app/views/api/pm/pipelines/index.json.jbuilder index c7ee9e545..430873132 100644 --- a/app/views/api/pm/pipelines/index.json.jbuilder +++ b/app/views/api/pm/pipelines/index.json.jbuilder @@ -1,6 +1,7 @@ json.status 0 json.message "success" -json.projects @has_pipeline_ids.each do |project_id| +json.count @pipelines.total_count +json.projects @pipelines.map(&:project_id).each do |project_id| json.id project_id project = Project.find_by(id: project_id) if project.present? From 2a1372cf5a72d47d6d382d7625989cc33a3a06ca Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 21 Apr 2025 14:02:03 +0800 Subject: [PATCH 30/45] =?UTF-8?q?fixed=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E7=94=9F=E6=88=90=EF=BC=8C=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 | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/api/pm/pipelines_controller.rb b/app/controllers/api/pm/pipelines_controller.rb index 0d42a9749..754d7718c 100644 --- a/app/controllers/api/pm/pipelines_controller.rb +++ b/app/controllers/api/pm/pipelines_controller.rb @@ -69,7 +69,6 @@ class Api::Pm::PipelinesController < Api::Pm::BaseController @pipelines = Action::Pipeline.where(project_id: @project_ids).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 = @pipelines @pipelines = paginate @pipelines end From 0f2419cd93457076c8e57c496c0b1ececdef3b44 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 21 Apr 2025 14:07:30 +0800 Subject: [PATCH 31/45] =?UTF-8?q?fixed=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E7=94=9F=E6=88=90=EF=BC=8C=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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/pm/pipelines_controller.rb b/app/controllers/api/pm/pipelines_controller.rb index 754d7718c..c1dd3411a 100644 --- a/app/controllers/api/pm/pipelines_controller.rb +++ b/app/controllers/api/pm/pipelines_controller.rb @@ -69,7 +69,7 @@ class Api::Pm::PipelinesController < Api::Pm::BaseController @pipelines = Action::Pipeline.where(project_id: @project_ids).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 = paginate @pipelines + @pipelines = kaminari_paginate(@pipelines) end end From 9b8de2457d08194459e238da9bb1641a7c97271d Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 21 Apr 2025 14:09:35 +0800 Subject: [PATCH 32/45] =?UTF-8?q?fixed=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/api/pm/pipelines/index.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/api/pm/pipelines/index.json.jbuilder b/app/views/api/pm/pipelines/index.json.jbuilder index 430873132..f13d013da 100644 --- a/app/views/api/pm/pipelines/index.json.jbuilder +++ b/app/views/api/pm/pipelines/index.json.jbuilder @@ -1,7 +1,7 @@ json.status 0 json.message "success" json.count @pipelines.total_count -json.projects @pipelines.map(&:project_id).each do |project_id| +json.projects @pipelines.map(&:project_id).uniq.each do |project_id| json.id project_id project = Project.find_by(id: project_id) if project.present? From 359446291751cd2531720b49bd69fc4d6f4dcfee Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 21 Apr 2025 15:03:38 +0800 Subject: [PATCH 33/45] =?UTF-8?q?fixed=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=90=8C=E6=97=B6=E5=88=A0=E9=99=A4=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/pipelines_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/api/v1/projects/pipelines_controller.rb b/app/controllers/api/v1/projects/pipelines_controller.rb index 98045e08d..8414f676f 100644 --- a/app/controllers/api/v1/projects/pipelines_controller.rb +++ b/app/controllers/api/v1/projects/pipelines_controller.rb @@ -148,6 +148,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController interactor = Gitea::DeleteFileInteractor.call(current_user.gitea_token, @owner.login, del_content_params(sha).merge(identifier: @project.identifier)) tip_exception(interactor.error) unless interactor.success? end + Gitea::ActionRun.where(repo_id: @pipeline.project.gpid).destroy_all @pipeline.destroy! end render_ok From a53f2e0eb9fea95e3cf46974b7e0ab5bb6c99049 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 21 Apr 2025 15:13:17 +0800 Subject: [PATCH 34/45] =?UTF-8?q?fixed=20=E7=BB=84=E7=BB=87=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=E7=BA=BF=E4=B8=AD=E5=A4=9A=E4=BB=93=E5=BA=93=E9=9A=94?= =?UTF-8?q?=E7=A6=BB?= 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 | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/pm/pipelines_controller.rb b/app/controllers/api/pm/pipelines_controller.rb index c1dd3411a..ac04a41ce 100644 --- a/app/controllers/api/pm/pipelines_controller.rb +++ b/app/controllers/api/pm/pipelines_controller.rb @@ -35,7 +35,7 @@ class Api::Pm::PipelinesController < Api::Pm::BaseController # 导入的流水线统一先禁用 $gitea_hat_client.post_repos_actions_disable(project&.owner&.login, project&.identifier, {query: {workflow: file}}) rescue nil end - last_action_run = action_runs.where(workflow_id: file).order(updated: :desc).first + last_action_run = action_runs.where(repo_id: project.gpid).where(workflow_id: file).order(updated: :desc).first last_action_run_json = last_action_run.present? ? { id: last_action_run.id, schedule: last_action_run.schedule_id > 0, @@ -58,6 +58,7 @@ class Api::Pm::PipelinesController < Api::Pm::BaseController failure += v if k[0] == file && k[1] == 2 end @run_result << { + repo_id: last_action_run.repo_id, filename: ".gitea/workflows/#{file}", total: total, success: success, diff --git a/app/views/api/pm/pipelines/index.json.jbuilder b/app/views/api/pm/pipelines/index.json.jbuilder index f13d013da..126adc477 100644 --- a/app/views/api/pm/pipelines/index.json.jbuilder +++ b/app/views/api/pm/pipelines/index.json.jbuilder @@ -19,7 +19,7 @@ json.projects @pipelines.map(&:project_id).uniq.each do |project_id| json.disable pipeline.disable end json.pipeline_type pipeline.pipeline_type - json.run_data @run_result.select { |result| result[:filename] == pipeline.file_name }.first + json.run_data @run_result.select { |result| result[:repo_id] == project.gpid && result[:filename] == pipeline.file_name}.first end end end From 44396e444b59f6e308f2464597cf2c1aec282d9b Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 21 Apr 2025 15:14:20 +0800 Subject: [PATCH 35/45] =?UTF-8?q?fixed=20=E7=BB=84=E7=BB=87=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=E7=BA=BF=E4=B8=AD=E5=A4=9A=E4=BB=93=E5=BA=93=E9=9A=94?= =?UTF-8?q?=E7=A6=BB=EF=BC=8C=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/pipelines_controller.rb | 2 +- app/views/api/v1/projects/pipelines/index.json.jbuilder | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v1/projects/pipelines_controller.rb b/app/controllers/api/v1/projects/pipelines_controller.rb index 8414f676f..25b95e547 100644 --- a/app/controllers/api/v1/projects/pipelines_controller.rb +++ b/app/controllers/api/v1/projects/pipelines_controller.rb @@ -59,7 +59,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController disabled_config = Gitea::RepoUnit.where(repo_id: @project.gpid, type: 10)&.first&.config @disabled_workflows = disabled_config.present? ? JSON.parse(disabled_config)["DisabledWorkflows"] : [] @pipelines = Action::Pipeline.where(project_id: @project.id).order(updated_at: :desc) - @pipelines = paginate @pipelines + @pipelines = kaminari_paginate(@pipelines) end def test_yaml diff --git a/app/views/api/v1/projects/pipelines/index.json.jbuilder b/app/views/api/v1/projects/pipelines/index.json.jbuilder index 81efa081a..65837ba7d 100644 --- a/app/views/api/v1/projects/pipelines/index.json.jbuilder +++ b/app/views/api/v1/projects/pipelines/index.json.jbuilder @@ -1,5 +1,6 @@ json.status 0 json.message "success" +json.count @pipelines.total_count json.pipelines @pipelines.each do |pipeline| json.extract! pipeline, :id, :pipeline_name, :pipeline_status, :description, :file_name, :is_graphic_design, From d3bc799263683507cbb34c6d32c1a662fb0317c0 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 21 Apr 2025 15:28:36 +0800 Subject: [PATCH 36/45] =?UTF-8?q?fixed=20=E7=BB=84=E7=BB=87=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=E7=BA=BF=E4=B8=AD=E5=A4=9A=E4=BB=93=E5=BA=93=E6=8C=89?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/pm/pipelines_controller.rb | 91 ++++++++++--------- .../api/v1/projects/pipelines_controller.rb | 2 +- 2 files changed, 48 insertions(+), 45 deletions(-) diff --git a/app/controllers/api/pm/pipelines_controller.rb b/app/controllers/api/pm/pipelines_controller.rb index ac04a41ce..e379eca78 100644 --- a/app/controllers/api/pm/pipelines_controller.rb +++ b/app/controllers/api/pm/pipelines_controller.rb @@ -16,56 +16,59 @@ class Api::Pm::PipelinesController < Api::Pm::BaseController db_files = pipelines.pluck(:file_name) @run_result = [] run_files.each do |file_info| - file = file_info.workflow_id + # file = file_info.workflow_id project = Project.find_by(gpid: file_info.repo_id) next if project.blank? - unless db_files.include?(".gitea/workflows/#{file}") - pipeline = Action::Pipeline.find_or_initialize_by(pipeline_name: file.to_s.gsub(".yml", "").gsub(".yaml", ""), - file_name: ".gitea/workflows/#{file}", - branch: project.default_branch, - is_graphic_design: false, - disable: false, - project_id: project.id) - interactor = Repositories::EntriesInteractor.call(@owner, project.identifier, ".gitea/workflows/#{file}", ref: project.default_branch) - if interactor.success? - pipeline.yaml = decode64_content(interactor.result, @owner, project.repository, project.default_branch, nil) + files = $gitea_client.get_repos_contents_by_owner_repo_filepath(project&.owner&.login, project&.identifier, ".gitea/workflows") rescue [] + files.map { |i| i['name'] }.each do |file| + unless db_files.include?(".gitea/workflows/#{file}") + pipeline = Action::Pipeline.find_or_initialize_by(pipeline_name: file.to_s.gsub(".yml", "").gsub(".yaml", ""), + file_name: ".gitea/workflows/#{file}", + branch: project.default_branch, + is_graphic_design: false, + disable: false, + project_id: project.id) + interactor = Repositories::EntriesInteractor.call(@owner, project.identifier, ".gitea/workflows/#{file}", ref: project.default_branch) + if interactor.success? + pipeline.yaml = decode64_content(interactor.result, @owner, project.repository, project.default_branch, nil) + end + pipeline.user_id = current_user.id + pipeline.save + # 导入的流水线统一先禁用 + $gitea_hat_client.post_repos_actions_disable(project&.owner&.login, project&.identifier, {query: {workflow: file}}) rescue nil end - pipeline.user_id = current_user.id - pipeline.save - # 导入的流水线统一先禁用 - $gitea_hat_client.post_repos_actions_disable(project&.owner&.login, project&.identifier, {query: {workflow: file}}) rescue nil - end - last_action_run = action_runs.where(repo_id: project.gpid).where(workflow_id: file).order(updated: :desc).first - last_action_run_json = last_action_run.present? ? { - id: last_action_run.id, - schedule: last_action_run.schedule_id > 0, - title: last_action_run.title, - index: last_action_run.index, - status: last_action_run.status, - started: last_action_run.started, - stopped: last_action_run.stopped, - length: last_action_run.stopped-last_action_run.started, - created: last_action_run.created, - updated: last_action_run.updated, - } : {} + last_action_run = action_runs.where(repo_id: project.gpid).where(workflow_id: file).order(updated: :desc).first + last_action_run_json = last_action_run.present? ? { + id: last_action_run.id, + schedule: last_action_run.schedule_id > 0, + title: last_action_run.title, + index: last_action_run.index, + status: last_action_run.status, + started: last_action_run.started, + stopped: last_action_run.stopped, + length: last_action_run.stopped-last_action_run.started, + created: last_action_run.created, + updated: last_action_run.updated, + } : {} - total = 0 - success = 0 - failure = 0 - group_data.each do |k,v| - total += v if k[0] == file - success += v if k[0] == file && k[1] == 1 - failure += v if k[0] == file && k[1] == 2 + total = 0 + success = 0 + failure = 0 + group_data.each do |k,v| + total += v if k[0] == file + success += v if k[0] == file && k[1] == 1 + failure += v if k[0] == file && k[1] == 2 + end + @run_result << { + repo_id: last_action_run.repo_id, + filename: ".gitea/workflows/#{file}", + total: total, + success: success, + failure: failure + }.merge(last_action_run_json) end - @run_result << { - repo_id: last_action_run.repo_id, - filename: ".gitea/workflows/#{file}", - total: total, - success: success, - failure: failure - }.merge(last_action_run_json) end - Rails.logger.info("@run_result======#{@run_result}") + # 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 = @pipelines.where("pipeline_name like ?", "%#{params[:pipeline_name]}%") if params[:pipeline_name].present? diff --git a/app/controllers/api/v1/projects/pipelines_controller.rb b/app/controllers/api/v1/projects/pipelines_controller.rb index 25b95e547..305cc974f 100644 --- a/app/controllers/api/v1/projects/pipelines_controller.rb +++ b/app/controllers/api/v1/projects/pipelines_controller.rb @@ -55,7 +55,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController failure: failure }.merge(last_action_run_json) end - Rails.logger.info("@run_result======#{@run_result}") + # Rails.logger.info("@run_result======#{@run_result}") disabled_config = Gitea::RepoUnit.where(repo_id: @project.gpid, type: 10)&.first&.config @disabled_workflows = disabled_config.present? ? JSON.parse(disabled_config)["DisabledWorkflows"] : [] @pipelines = Action::Pipeline.where(project_id: @project.id).order(updated_at: :desc) From 88415e256ddf24d756087ea331fdb5aef168db6c Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 21 Apr 2025 15:53:04 +0800 Subject: [PATCH 37/45] =?UTF-8?q?fixed=20=E7=BB=84=E7=BB=87=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=E7=BA=BF=E8=BF=90=E8=A1=8C=E6=95=B0=E6=8D=AE=E6=8E=A7?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/pm/pipelines_controller.rb | 91 +++++++++---------- .../api/pm/pipelines/index.json.jbuilder | 6 +- 2 files changed, 49 insertions(+), 48 deletions(-) diff --git a/app/controllers/api/pm/pipelines_controller.rb b/app/controllers/api/pm/pipelines_controller.rb index e379eca78..a69e3ac81 100644 --- a/app/controllers/api/pm/pipelines_controller.rb +++ b/app/controllers/api/pm/pipelines_controller.rb @@ -16,57 +16,54 @@ class Api::Pm::PipelinesController < Api::Pm::BaseController db_files = pipelines.pluck(:file_name) @run_result = [] run_files.each do |file_info| - # file = file_info.workflow_id + file = file_info.workflow_id project = Project.find_by(gpid: file_info.repo_id) next if project.blank? - files = $gitea_client.get_repos_contents_by_owner_repo_filepath(project&.owner&.login, project&.identifier, ".gitea/workflows") rescue [] - files.map { |i| i['name'] }.each do |file| - unless db_files.include?(".gitea/workflows/#{file}") - pipeline = Action::Pipeline.find_or_initialize_by(pipeline_name: file.to_s.gsub(".yml", "").gsub(".yaml", ""), - file_name: ".gitea/workflows/#{file}", - branch: project.default_branch, - is_graphic_design: false, - disable: false, - project_id: project.id) - interactor = Repositories::EntriesInteractor.call(@owner, project.identifier, ".gitea/workflows/#{file}", ref: project.default_branch) - if interactor.success? - pipeline.yaml = decode64_content(interactor.result, @owner, project.repository, project.default_branch, nil) - end - pipeline.user_id = current_user.id - pipeline.save - # 导入的流水线统一先禁用 - $gitea_hat_client.post_repos_actions_disable(project&.owner&.login, project&.identifier, {query: {workflow: file}}) rescue nil + unless db_files.include?(".gitea/workflows/#{file}") + pipeline = Action::Pipeline.find_or_initialize_by(pipeline_name: file.to_s.gsub(".yml", "").gsub(".yaml", ""), + file_name: ".gitea/workflows/#{file}", + branch: project.default_branch, + is_graphic_design: false, + disable: false, + project_id: project.id) + interactor = Repositories::EntriesInteractor.call(@owner, project.identifier, ".gitea/workflows/#{file}", ref: project.default_branch) + if interactor.success? + pipeline.yaml = decode64_content(interactor.result, @owner, project.repository, project.default_branch, nil) end - last_action_run = action_runs.where(repo_id: project.gpid).where(workflow_id: file).order(updated: :desc).first - last_action_run_json = last_action_run.present? ? { - id: last_action_run.id, - schedule: last_action_run.schedule_id > 0, - title: last_action_run.title, - index: last_action_run.index, - status: last_action_run.status, - started: last_action_run.started, - stopped: last_action_run.stopped, - length: last_action_run.stopped-last_action_run.started, - created: last_action_run.created, - updated: last_action_run.updated, - } : {} - - total = 0 - success = 0 - failure = 0 - group_data.each do |k,v| - total += v if k[0] == file - success += v if k[0] == file && k[1] == 1 - failure += v if k[0] == file && k[1] == 2 - end - @run_result << { - repo_id: last_action_run.repo_id, - filename: ".gitea/workflows/#{file}", - total: total, - success: success, - failure: failure - }.merge(last_action_run_json) + pipeline.user_id = current_user.id + pipeline.save + # 导入的流水线统一先禁用 + $gitea_hat_client.post_repos_actions_disable(project&.owner&.login, project&.identifier, {query: {workflow: file}}) rescue nil end + last_action_run = action_runs.where(repo_id: project.gpid).where(workflow_id: file).order(updated: :desc).first + last_action_run_json = last_action_run.present? ? { + id: last_action_run.id, + schedule: last_action_run.schedule_id > 0, + title: last_action_run.title, + index: last_action_run.index, + status: last_action_run.status, + started: last_action_run.started, + stopped: last_action_run.stopped, + length: last_action_run.stopped-last_action_run.started, + created: last_action_run.created, + updated: last_action_run.updated, + } : {} + + total = 0 + success = 0 + failure = 0 + group_data.each do |k,v| + total += v if k[0] == file + success += v if k[0] == file && k[1] == 1 + failure += v if k[0] == file && k[1] == 2 + end + @run_result << { + repo_id: last_action_run.repo_id, + filename: ".gitea/workflows/#{file}", + total: total, + success: success, + failure: failure + }.merge(last_action_run_json) end # Rails.logger.info("@run_result======#{@run_result}") @disabled_workflows = Gitea::RepoUnit.where(repo_id: project_gpids, type: 10).where("config is not null") diff --git a/app/views/api/pm/pipelines/index.json.jbuilder b/app/views/api/pm/pipelines/index.json.jbuilder index 126adc477..7ae7abd40 100644 --- a/app/views/api/pm/pipelines/index.json.jbuilder +++ b/app/views/api/pm/pipelines/index.json.jbuilder @@ -19,7 +19,11 @@ json.projects @pipelines.map(&:project_id).uniq.each do |project_id| json.disable pipeline.disable end json.pipeline_type pipeline.pipeline_type - json.run_data @run_result.select { |result| result[:repo_id] == project.gpid && result[:filename] == pipeline.file_name}.first + if pipeline.json.blank? && pipeline.yaml.blank? + json.run_data nil + else + json.run_data @run_result.select { |result| result[:repo_id] == project.gpid && result[:filename] == pipeline.file_name}.first + end end end end From 7ff07e9c29b25d25588ff9b88ba4b70b5b1fe7e3 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 21 Apr 2025 16:05:29 +0800 Subject: [PATCH 38/45] =?UTF-8?q?fixed=20=E7=BB=84=E7=BB=87=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=E7=BA=BF=E8=BF=90=E8=A1=8C=E6=95=B0=E6=8D=AE=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E6=98=AF=E5=90=A6=E6=9C=89=E6=96=87=E4=BB=B6=E5=AD=98?= =?UTF-8?q?=E5=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v1/projects/actions/runs_controller.rb | 9 ++-- .../projects/actions/runs/index.json.jbuilder | 43 +++++++++++-------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/app/controllers/api/v1/projects/actions/runs_controller.rb b/app/controllers/api/v1/projects/actions/runs_controller.rb index cdde508a1..162aa84cb 100644 --- a/app/controllers/api/v1/projects/actions/runs_controller.rb +++ b/app/controllers/api/v1/projects/actions/runs_controller.rb @@ -1,9 +1,12 @@ class Api::V1::Projects::Actions::RunsController < Api::V1::Projects::Actions::BaseController def index - @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 + @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 + end end def create diff --git a/app/views/api/v1/projects/actions/runs/index.json.jbuilder b/app/views/api/v1/projects/actions/runs/index.json.jbuilder index e0a8aa189..3014aa6d7 100644 --- a/app/views/api/v1/projects/actions/runs/index.json.jbuilder +++ b/app/views/api/v1/projects/actions/runs/index.json.jbuilder @@ -1,24 +1,29 @@ -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| - json.num @result_object[:total_data].to_i - @begin_num - index - json.workflow run["WorkflowID"] - json.index run["Index"] - json.title run["Title"] - json.trigger_user do - json.partial! 'api/v1/users/commit_user', locals: { user: render_cache_commit_author(run['TriggerUser']), name: run['TriggerUser']['Name'] } - end +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| + json.num @result_object[:total_data].to_i - @begin_num - index + json.workflow run["WorkflowID"] + json.index run["Index"] + json.title run["Title"] + json.trigger_user do + json.partial! 'api/v1/users/commit_user', locals: { user: render_cache_commit_author(run['TriggerUser']), name: run['TriggerUser']['Name'] } + end - if run["Ref"].starts_with?("refs/tags") - json.ref run["Ref"].gsub!("/refs/tags/", "") - else - json.ref run["Ref"].gsub!("refs/heads/", "") - end + if run["Ref"].starts_with?("refs/tags") + json.ref run["Ref"].gsub!("/refs/tags/", "") + else + json.ref run["Ref"].gsub!("refs/heads/", "") + end - json.status run["Status"] - json.time_ago time_from_now(run["Created"]) - json.holding_time run["Status"] == 6 ? Time.now.to_i - run["Created"] : run["Stopped"] - run["Created"] + json.status run["Status"] + json.time_ago time_from_now(run["Created"]) + json.holding_time run["Status"] == 6 ? Time.now.to_i - run["Created"] : run["Stopped"] - run["Created"] + end + else + json.runs [] end else - json.runs [] + json.total_data 0 + json.runs [] end \ No newline at end of file From 9c593b1271e00cbc3f1c0c99ad45d36b8d30147c Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 21 Apr 2025 16:25:39 +0800 Subject: [PATCH 39/45] =?UTF-8?q?fixed=20=E7=BB=84=E7=BB=87=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=E7=BA=BF=E8=BF=90=E8=A1=8C=E6=95=B0=E6=8D=AE=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E6=98=AF=E5=90=A6=E6=9C=89=E6=96=87=E4=BB=B6=E5=AD=98?= =?UTF-8?q?=E5=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/actions/runs_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/v1/projects/actions/runs_controller.rb b/app/controllers/api/v1/projects/actions/runs_controller.rb index 162aa84cb..3e9e2024c 100644 --- a/app/controllers/api/v1/projects/actions/runs_controller.rb +++ b/app/controllers/api/v1/projects/actions/runs_controller.rb @@ -1,7 +1,7 @@ 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 [] + @files = $gitea_client.get_repos_contents_by_owner_repo_filepath(@project&.owner&.login, @project&.identifier, ".gitea/workflows") 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) From b4da913f2b32853868594d6da3e00224fe038216 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 21 Apr 2025 16:53:33 +0800 Subject: [PATCH 40/45] =?UTF-8?q?fixed=20=E7=BB=84=E7=BB=87=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=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 } From 492561c405393177ebaceafaf5008bfdd033cb0e Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 21 Apr 2025 16:56:18 +0800 Subject: [PATCH 41/45] =?UTF-8?q?fixed=20=E7=BB=84=E7=BB=87=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=E7=BA=BF=E6=8C=89=E4=BB=93=E5=BA=93=E5=88=86=E9=A1=B5?= =?UTF-8?q?sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/pm/pipelines_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/pm/pipelines_controller.rb b/app/controllers/api/pm/pipelines_controller.rb index 3ddfa350b..933417ff2 100644 --- a/app/controllers/api/pm/pipelines_controller.rb +++ b/app/controllers/api/pm/pipelines_controller.rb @@ -68,7 +68,7 @@ class Api::Pm::PipelinesController < Api::Pm::BaseController # 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.select("distinct project_id,max(updated_at) as updated_at") - .where(project_id: @project_ids).group(:project_id).order(updated_at: :desc) + .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) From ed8593071fb7c4f23376772a0e7bc4a8401ce425 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 21 Apr 2025 17:05:08 +0800 Subject: [PATCH 42/45] =?UTF-8?q?fixed=20=E7=BB=84=E7=BB=87=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=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/views/api/pm/pipelines/index.json.jbuilder | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/api/pm/pipelines/index.json.jbuilder b/app/views/api/pm/pipelines/index.json.jbuilder index 9322ae210..cd7051877 100644 --- a/app/views/api/pm/pipelines/index.json.jbuilder +++ b/app/views/api/pm/pipelines/index.json.jbuilder @@ -9,8 +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 |id| - pipeline = Action::Pipeline.find_by(id: id) + pipelines = Action::Pipeline.where(project_id: @project.id).order(updated_at: :desc) + json.pipelines pipelines.each do |pipeline| 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 } From 3d9f037025fc17072d918eace602bf5b2856a534 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 21 Apr 2025 17:07:07 +0800 Subject: [PATCH 43/45] =?UTF-8?q?fixed=20=E7=BB=84=E7=BB=87=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=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/views/api/pm/pipelines/index.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/api/pm/pipelines/index.json.jbuilder b/app/views/api/pm/pipelines/index.json.jbuilder index cd7051877..462c31594 100644 --- a/app/views/api/pm/pipelines/index.json.jbuilder +++ b/app/views/api/pm/pipelines/index.json.jbuilder @@ -9,7 +9,7 @@ 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}" - pipelines = Action::Pipeline.where(project_id: @project.id).order(updated_at: :desc) + pipelines = Action::Pipeline.where(project_id: project.id).order(updated_at: :desc) json.pipelines pipelines.each do |pipeline| 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 From 5c62b1d129a99088ca68f51e76192592b40d33f5 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 21 Apr 2025 17:17:10 +0800 Subject: [PATCH 44/45] =?UTF-8?q?fixed=20=E7=BB=84=E7=BB=87=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=E7=BA=BF=E5=90=AF=E7=94=A8=E7=A6=81=E7=94=A8=E7=8A=B6?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/api/pm/pipelines/index.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/api/pm/pipelines/index.json.jbuilder b/app/views/api/pm/pipelines/index.json.jbuilder index 462c31594..d7cfc23bb 100644 --- a/app/views/api/pm/pipelines/index.json.jbuilder +++ b/app/views/api/pm/pipelines/index.json.jbuilder @@ -13,7 +13,7 @@ json.projects @pipelines.map(&:project_id).uniq.each do |project_id| json.pipelines pipelines.each do |pipeline| 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 } + repo_config = @disabled_workflows.select { |config| config.repo_id == pipeline.project.gpid } if repo_config.present? json.disable JSON.parse(repo_config.first.config)["DisabledWorkflows"].to_s.include?(pipeline.file_name.to_s.gsub(".gitea/workflows/", "")) else From 558bcfeefa8cf76f37ab4c7005237ee42b87633f Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 7 May 2025 08:45:04 +0800 Subject: [PATCH 45/45] fixed add users phone index --- db/migrate/202505071325549_add_user_index_phone.rb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 db/migrate/202505071325549_add_user_index_phone.rb diff --git a/db/migrate/202505071325549_add_user_index_phone.rb b/db/migrate/202505071325549_add_user_index_phone.rb new file mode 100644 index 000000000..5ccae98b8 --- /dev/null +++ b/db/migrate/202505071325549_add_user_index_phone.rb @@ -0,0 +1,5 @@ +class AddUserIndexPhone < ActiveRecord::Migration[5.2] + def change + add_index :users, :phone + end +end