Commit f903f0b6 authored by Sean Arnold's avatar Sean Arnold

Use same graphql arugments at column names

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