2019-03-22 12:51:47 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class MergeRequestAssignee < ApplicationRecord
|
2020-09-04 20:08:43 -04:00
|
|
|
belongs_to :merge_request, touch: true
|
2020-06-23 11:08:41 -04:00
|
|
|
belongs_to :assignee, class_name: "User", foreign_key: :user_id, inverse_of: :merge_request_assignees
|
2020-01-28 19:08:58 -05:00
|
|
|
|
|
|
|
validates :assignee, uniqueness: { scope: :merge_request_id }
|
2020-06-23 11:08:41 -04:00
|
|
|
|
2021-04-26 08:09:44 -04:00
|
|
|
scope :in_projects, ->(project_ids) { joins(:merge_request).where(merge_requests: { target_project_id: project_ids }) }
|
2021-11-08 01:09:59 -05:00
|
|
|
|
|
|
|
def cache_key
|
2022-08-25 08:12:20 -04:00
|
|
|
[model_name.cache_key, id, assignee.cache_key]
|
2021-11-08 01:09:59 -05:00
|
|
|
end
|
2019-03-22 12:51:47 -04:00
|
|
|
end
|