FIX sync update closed issues count

This commit is contained in:
Jasder 2020-05-21 18:37:32 +08:00
parent becca7d1ae
commit e14e6230c7
3 changed files with 14 additions and 7 deletions

View File

@ -208,13 +208,14 @@ class IssuesController < ApplicationController
if params[:status_id].to_i == 5
@issue.issue_times.update_all(end_time: Time.now)
@issue.update_closed_issues_count_in_project!
end
if @issue.issue_type.to_s == "2"
if @issue.issue_type.to_s == "2"
#表示修改token值
if @issue.saved_change_to_attribute("token")
last_token = @issue.token_was
change_token = last_token - @issue.token
change_token = last_token - @issue.token
change_type = change_token > 0 ? "addToken" : "minusToken"
change_params = {
change_type: change_type,
@ -222,7 +223,7 @@ class IssuesController < ApplicationController
}.merge(tokens_params(@proeject))
ChangeTokenJob.perform_later(change_params)
end
end
@issue.create_journal_detail(change_files, issue_files, issue_file_ids, current_user&.id)
@ -433,6 +434,6 @@ class IssuesController < ApplicationController
reponame: project.try(:identifer),
username: current_user.try(:login)
}
end
end

View File

@ -25,6 +25,7 @@ class Issue < ApplicationRecord
scope :issue_index_includes, ->{includes(:user,:tracker, :priority, :version, :issue_status, :journals, :issue_times)}
after_update :change_versions_count
after_destroy :update_closed_issues_count_in_project!
def get_assign_user
@ -102,4 +103,8 @@ class Issue < ApplicationRecord
end
end
def update_closed_issues_count_in_project!
self.project.decrement!(:closed_issues_count)
end
end

View File

@ -118,9 +118,6 @@ class Project < ApplicationRecord
members.select(:id).size
end
def issues_count
issues.select(:id).size
end
def can_visited?
is_public? || User.current.admin? || member?(User.current)
@ -138,4 +135,8 @@ class Project < ApplicationRecord
self.pull_requests.select(:user_id).pluck(:user_id).uniq.size
end
def open_issues_count
issues_count - closed_issues_count
end
end