Skip to content
Snippets Groups Projects
Commit 838a90fe authored by Sean Arnold's avatar Sean Arnold :one:
Browse files

Use consistent execution time. Un-null a field

parent 077b9a1d
No related branches found
No related tags found
1 merge request!68237Add oncall_users to oncall schedule Graphql type
...@@ -10161,7 +10161,7 @@ Describes an incident management on-call schedule. ...@@ -10161,7 +10161,7 @@ Describes an incident management on-call schedule.
| <a id="incidentmanagementoncallscheduledescription"></a>`description` | [`String`](#string) | Description of the on-call schedule. | | <a id="incidentmanagementoncallscheduledescription"></a>`description` | [`String`](#string) | Description of the on-call schedule. |
| <a id="incidentmanagementoncallscheduleiid"></a>`iid` | [`ID!`](#id) | Internal ID of the on-call schedule. | | <a id="incidentmanagementoncallscheduleiid"></a>`iid` | [`ID!`](#id) | Internal ID of the on-call schedule. |
| <a id="incidentmanagementoncallschedulename"></a>`name` | [`String!`](#string) | Name of the on-call schedule. | | <a id="incidentmanagementoncallschedulename"></a>`name` | [`String!`](#string) | Name of the on-call schedule. |
| <a id="incidentmanagementoncallscheduleoncallusers"></a>`oncallUsers` | [`[UserCore!]!`](#usercore) | | | <a id="incidentmanagementoncallscheduleoncallusers"></a>`oncallUsers` | [`[UserCore!]`](#usercore) | |
| <a id="incidentmanagementoncallschedulerotations"></a>`rotations` | [`IncidentManagementOncallRotationConnection!`](#incidentmanagementoncallrotationconnection) | On-call rotations for the on-call schedule. (see [Connections](#connections)) | | <a id="incidentmanagementoncallschedulerotations"></a>`rotations` | [`IncidentManagementOncallRotationConnection!`](#incidentmanagementoncallrotationconnection) | On-call rotations for the on-call schedule. (see [Connections](#connections)) |
| <a id="incidentmanagementoncallscheduletimezone"></a>`timezone` | [`String!`](#string) | Time zone of the on-call schedule. | | <a id="incidentmanagementoncallscheduletimezone"></a>`timezone` | [`String!`](#string) | Time zone of the on-call schedule. |
   
......
...@@ -18,6 +18,8 @@ class EscalationPoliciesResolver < BaseResolver ...@@ -18,6 +18,8 @@ class EscalationPoliciesResolver < BaseResolver
end end
def resolve_with_lookahead(**args) def resolve_with_lookahead(**args)
context[:execution_time] = Time.current
apply_lookahead(::IncidentManagement::EscalationPoliciesFinder.new(current_user, project, args).execute) apply_lookahead(::IncidentManagement::EscalationPoliciesFinder.new(current_user, project, args).execute)
end end
......
...@@ -8,7 +8,9 @@ class OncallUsersResolver < BaseResolver ...@@ -8,7 +8,9 @@ class OncallUsersResolver < BaseResolver
type [::Types::UserType], null: true type [::Types::UserType], null: true
def resolve def resolve
::IncidentManagement::OncallUsersFinder.new(schedule.project, schedule: schedule).execute oncall_at = context[:execution_time] || Time.current
::IncidentManagement::OncallUsersFinder.new(schedule.project, schedule: schedule, oncall_at: oncall_at).execute
end end
end end
end end
......
...@@ -41,7 +41,7 @@ class OncallScheduleType < BaseObject ...@@ -41,7 +41,7 @@ class OncallScheduleType < BaseObject
field :oncall_users, field :oncall_users,
[::Types::UserType], [::Types::UserType],
null: false, null: true,
resolver: ::Resolvers::IncidentManagement::OncallUsersResolver resolver: ::Resolvers::IncidentManagement::OncallUsersResolver
end end
end end
......
...@@ -24,6 +24,17 @@ ...@@ -24,6 +24,17 @@
expect(schedule.participants.pluck(:user_id)).to include(users.first.id) expect(schedule.participants.pluck(:user_id)).to include(users.first.id)
end end
it 'calls the finder with the execution_time context' do
execution_time = Time.current
context = { current_user: current_user, execution_time: execution_time }
expect(::IncidentManagement::OncallUsersFinder).to receive(:new)
.with(project, hash_including(oncall_at: execution_time))
.and_call_original
resolve_oncall_users({}, context)
end
context 'when an error occurs while finding shifts' do context 'when an error occurs while finding shifts' do
before do before do
stub_licensed_features(oncall_schedules: false) stub_licensed_features(oncall_schedules: false)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment