Skip to content
Snippets Groups Projects
Commit f903f0b6 authored by Sean Arnold's avatar Sean Arnold :speech_balloon:
Browse files

Use same graphql arugments at column names

Small tweaks
Update docs
parent 16f0516f
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -2810,8 +2810,8 @@ Active period time range for on-call rotation.
 
| Field | Type | Description |
| ----- | ---- | ----------- |
| `from` | String | The start of the rotation interval. |
| `to` | String | The end of the rotation interval. |
| `endTime` | String | The end of the rotation active period. |
| `startTime` | String | The start of the rotation active period. |
 
### OncallRotationCreatePayload
 
Loading
Loading
Loading
Loading
@@ -75,8 +75,8 @@ def create_service_params(schedule, participants, args)
rotation_length_unit = args[:rotation_length][:unit]
starts_at = parse_datetime(schedule, args[:starts_at])
ends_at = parse_datetime(schedule, args[:ends_at]) if args[:ends_at]
active_period_start = args.dig(:active_period, :from)
active_period_end = args.dig(:active_period, :to)
active_period_start = args.dig(:active_period, :start_time)
active_period_end = args.dig(:active_period, :end_time)
 
args.slice(:name).merge(
length: rotation_length,
Loading
Loading
Loading
Loading
@@ -7,25 +7,25 @@ class OncallRotationActivePeriodInputType < BaseInputObject
graphql_name 'OncallRotationActivePeriodInputType'
description 'Active period time range for on-call rotation'
 
argument :from, GraphQL::STRING_TYPE,
argument :start_time, GraphQL::STRING_TYPE,
required: true,
description: 'The start of the rotation interval.'
description: 'The start of the rotation active period.'
 
argument :to, GraphQL::STRING_TYPE,
argument :end_time, GraphQL::STRING_TYPE,
required: true,
description: 'The end of the rotation interval.'
description: 'The end of the rotation active period..'
 
TIME_FORMAT = %r[^(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$].freeze
 
def prepare
raise invalid_time_error unless TIME_FORMAT.match?(from)
raise invalid_time_error unless TIME_FORMAT.match?(to)
raise invalid_time_error unless TIME_FORMAT.match?(start_time)
raise invalid_time_error unless TIME_FORMAT.match?(end_time)
 
parsed_from = Time.parse(from)
parsed_to = Time.parse(to)
parsed_from = Time.parse(start_time)
parsed_to = Time.parse(end_time)
 
if parsed_to < parsed_from
raise ::Gitlab::Graphql::Errors::ArgumentError, "'from' time must be before 'to' time"
raise ::Gitlab::Graphql::Errors::ArgumentError, "'start_time' time must be before 'end_time' time"
end
 
to_h
Loading
Loading
Loading
Loading
@@ -7,20 +7,22 @@ class OncallRotationActivePeriodType < BaseObject
graphql_name 'OncallRotationActivePeriodType'
description 'Active period time range for on-call rotation'
 
field :from, GraphQL::STRING_TYPE,
null: true,
description: 'The start of the rotation interval.'
field :start_time, GraphQL::STRING_TYPE,
null: true,
description: 'The start of the rotation active period.'
 
field :to, GraphQL::STRING_TYPE,
null: true,
description: 'The end of the rotation interval.'
field :end_time, GraphQL::STRING_TYPE,
null: true,
description: 'The end of the rotation active period.'
alias_method :active_period, :object
 
def from
object.start_time&.strftime('%H:%M')
active_period.start_time&.strftime('%H:%M')
end
 
def to
object.end_time&.strftime('%H:%M')
active_period.end_time&.strftime('%H:%M')
end
end
# rubocop: enable Graphql/AuthorizeTypes
Loading
Loading
Loading
Loading
@@ -53,14 +53,6 @@ class OncallRotationType < BaseObject
null: true,
description: 'Blocks of time for which a participant is on-call within a given time frame. Time frame cannot exceed one month.',
resolver: ::Resolvers::IncidentManagement::OncallShiftsResolver
def active_period_start
object.active_period_start&.strftime('%H:%M')
end
def active_period_end
object.active_period_end&.strftime('%H:%M')
end
end
end
end
Loading
Loading
@@ -85,8 +85,8 @@
context 'with active period times given' do
before do
args[:active_period] = {
from: '08:00',
to: '17:00'
start_time: '08:00',
end_time: '17:00'
}
end
 
Loading
Loading
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