2020-08-30 20:10:37 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class MergeRequestReviewer < ApplicationRecord
|
2021-10-25 05:12:21 -04:00
|
|
|
include MergeRequestReviewerState
|
2021-02-02 07:10:15 -05:00
|
|
|
|
2020-08-30 20:10:37 -04:00
|
|
|
belongs_to :merge_request
|
2020-11-23 13:09:14 -05:00
|
|
|
belongs_to :reviewer, class_name: 'User', foreign_key: :user_id, inverse_of: :merge_request_reviewers
|
2021-11-08 01:09:59 -05:00
|
|
|
|
2021-12-02 04:10:59 -05:00
|
|
|
def set_state
|
|
|
|
if Feature.enabled?(:mr_attention_requests, self.merge_request&.project, default_enabled: :yaml)
|
|
|
|
self.state = MergeRequestAssignee.find_by(user_id: self.user_id, merge_request_id: self.merge_request_id)&.state || :attention_requested
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-11-08 01:09:59 -05:00
|
|
|
def cache_key
|
|
|
|
[model_name.cache_key, id, state, reviewer.cache_key]
|
|
|
|
end
|
2020-08-30 20:10:37 -04:00
|
|
|
end
|