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