Commit a1f74822 authored by Sean Arnold's avatar Sean Arnold

Add OncallScheduleEntity with data to members

- Preload associations
parent 4c99bf93
......@@ -9,6 +9,7 @@ module EE
super
ActiveRecord::Associations::Preloader.new.preload(members.map(&:user), group_saml_identities: :saml_provider)
ActiveRecord::Associations::Preloader.new.preload(members.map(&:user), oncall_participants: { rotation: :schedule })
end
end
end
......@@ -73,6 +73,10 @@ module EE
has_many :user_permission_export_uploads
has_many :oncall_participants, class_name: 'IncidentManagement::OncallParticipant', inverse_of: :user
has_many :oncall_rotations, class_name: 'IncidentManagement::OncallRotation', through: :oncall_participants, source: :rotation
has_many :oncall_schedules, class_name: 'IncidentManagement::OncallSchedule', through: :oncall_rotations, source: :schedule
scope :not_managed, ->(group: nil) {
scope = where(managing_group_id: nil)
scope = scope.or(where.not(managing_group_id: group.id)) if group
......
......@@ -22,6 +22,10 @@ module IncidentManagement
scope :for_iid, -> (iid) { where(iid: iid) }
def project_name
project.name
end
private
def timezones
......
......@@ -7,6 +7,7 @@ module EE
prepended do
unexpose :gitlab_employee
unexpose :email
expose :oncall_schedules, with: ::IncidentManagement::OncallScheduleEntity
end
end
end
# frozen_string_literal: true
module IncidentManagement
class OncallScheduleEntity < Grape::Entity
expose :name
expose :project_name
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment