FIX pull request bug

(cherry picked from commit 2b140d6f7c)
This commit is contained in:
Jasder
2021-01-12 15:45:18 +08:00
committed by moshenglv
parent 20b06473be
commit d2e2793d29
11 changed files with 219 additions and 26 deletions

View File

@@ -17,6 +17,13 @@
#
class IssueStatus < ApplicationRecord
ADD = 1
SOLVING = 2
SOLVED = 3
FEEDBACK = 4
CLOSED = 5
REJECTED = 6
has_many :issues
belongs_to :project, optional: true
end

View File

@@ -18,6 +18,9 @@
#
class ProjectTrend < ApplicationRecord
CLOSE = 'close'
CREATE = 'create'
belongs_to :project
belongs_to :trend, polymorphic: true, optional: true
belongs_to :user

View File

@@ -24,7 +24,11 @@
#
class PullRequest < ApplicationRecord
#status 0 默认未合并, 1表示合并, 2表示请求拒绝
#status 0 默认未合并, 1表示合并, 2表示请求拒绝(或已关闭)
OPEN = 0
MERGED = 1
CLOSED = 2
belongs_to :issue
belongs_to :user
belongs_to :project, :counter_cache => true
@@ -42,6 +46,14 @@ class PullRequest < ApplicationRecord
update_column(:gpid, gitea_pull_number)
end
def merge!
update_column(:status, PullRequest::MERGED)
end
def project_trend_status!
self&.project_trends&.update_all(action_type: ProjectTrend::CLOSE)
end
# TODO: sync educoder platform repo's for update some statistics count
def self.update_some_count
PullRequest.includes(:user, :project).select(:id, :user_id, :gpid, :project_id, :fork_project_id).each do |pr|