FIX 优化ci流程,并配置gitea相关database

This commit is contained in:
Jasder
2020-09-27 11:30:37 +08:00
parent 6cbb22acaf
commit a308862567
9 changed files with 138 additions and 27 deletions

View File

@@ -57,4 +57,8 @@ class Ci::Repo < Ci::RemoteBase
repo
end
end
def deactivate!
update_column(:repo_active, 0)
end
end

View File

@@ -21,6 +21,22 @@ module Droneable
devops_unverified? && Ci::User.exists?(user_login: self.login)
end
def unbind_account!
user_projects = selef.projects
user_projects.update_all(open_devops: false, open_devops_count: 0)
set_drone_step!(User::DEVOPS_UNINIT)
# TODO
# 删除用户项目下的与ci相关的所有webhook
user_projects.select(:id, :identifier, :gitea_webhook_id).each do |project|
if project.gitea_webhook_id
result = Gitea::Hooks::DestroyService.call(self.gitea_token, self.login, project.identifier, project.gitea_webhook_id)
project.update_column(:gitea_webhook_id, nil) if result.status == 204
end
end
end
module ClassMethods
end
end

View File

@@ -180,4 +180,14 @@ class Project < ApplicationRecord
return nil if project.blank?
project
end
def ci_reactivate?
open_devops_count > 0
end
def ci_reactivate!(ci_repo)
ci_repo.update_column(:repo_active, 1)
update_column(:open_devops, true)
increment!(:open_devops_count)
end
end