2018-07-25 05:30:33 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-03-28 09:17:42 -04:00
|
|
|
class IssueAssignee < ApplicationRecord
|
2017-05-04 08:11:15 -04:00
|
|
|
belongs_to :issue
|
2020-06-23 11:08:41 -04:00
|
|
|
belongs_to :assignee, class_name: "User", foreign_key: :user_id, inverse_of: :issue_assignees
|
2020-01-28 19:08:58 -05:00
|
|
|
|
|
|
|
validates :assignee, uniqueness: { scope: :issue_id }
|
2020-06-23 11:08:41 -04:00
|
|
|
|
|
|
|
scope :in_projects, ->(project_ids) { joins(:issue).where("issues.project_id in (?)", project_ids) }
|
|
|
|
scope :on_issues, ->(issue_ids) { where(issue_id: issue_ids) }
|
2020-10-12 14:08:31 -04:00
|
|
|
scope :for_assignee, ->(user) { where(assignee: user) }
|
2017-05-04 08:11:15 -04:00
|
|
|
end
|
2019-09-13 09:26:31 -04:00
|
|
|
|
|
|
|
IssueAssignee.prepend_if_ee('EE::IssueAssignee')
|