|
|
@ -6,7 +6,7 @@ class Issue < ApplicationRecord
|
|
|
|
has_one :pull_request
|
|
|
|
has_one :pull_request
|
|
|
|
# belongs_to :issue_tag,optional: true
|
|
|
|
# belongs_to :issue_tag,optional: true
|
|
|
|
belongs_to :priority, :class_name => 'IssuePriority', foreign_key: :priority_id,optional: true
|
|
|
|
belongs_to :priority, :class_name => 'IssuePriority', foreign_key: :priority_id,optional: true
|
|
|
|
belongs_to :version, foreign_key: :fixed_version_id,optional: true
|
|
|
|
belongs_to :version, foreign_key: :fixed_version_id,optional: true, counter_cache: true
|
|
|
|
belongs_to :user,optional: true, foreign_key: :author_id
|
|
|
|
belongs_to :user,optional: true, foreign_key: :author_id
|
|
|
|
belongs_to :issue_status, foreign_key: :status_id,optional: true
|
|
|
|
belongs_to :issue_status, foreign_key: :status_id,optional: true
|
|
|
|
has_many :commit_issues
|
|
|
|
has_many :commit_issues
|
|
|
@ -23,6 +23,8 @@ class Issue < ApplicationRecord
|
|
|
|
scope :issue_issue, ->{where(issue_classify: [nil,"issue"])}
|
|
|
|
scope :issue_issue, ->{where(issue_classify: [nil,"issue"])}
|
|
|
|
scope :issue_pull_request, ->{where(issue_classify: "pull_request")}
|
|
|
|
scope :issue_pull_request, ->{where(issue_classify: "pull_request")}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
after_save :change_versions_count
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_assign_user
|
|
|
|
def get_assign_user
|
|
|
|
User.select(:login, :lastname,:firstname, :nickname)&.find_by_id(self.assigned_to_id)
|
|
|
|
User.select(:login, :lastname,:firstname, :nickname)&.find_by_id(self.assigned_to_id)
|
|
|
@ -87,4 +89,11 @@ class Issue < ApplicationRecord
|
|
|
|
journals.where.not(notes: [nil, ""]).journal_includes.limit(2)
|
|
|
|
journals.where.not(notes: [nil, ""]).journal_includes.limit(2)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def change_versions_count
|
|
|
|
|
|
|
|
if version.present? && self.status_id == 5
|
|
|
|
|
|
|
|
percent = version.issues_count == 0 ? 0.0 : ((version.closed_issues_count + 1) / version.issues_count)
|
|
|
|
|
|
|
|
version.update_attributes(closed_issues_count: (version.closed_issues_count + 1), percent: percent)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|