Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 59 additions & 6 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ Lint/MissingCopEnableDirective:
- 'test/graphql/mutations/update_event_proposal_test.rb'
- 'test/graphql/mutations/update_event_test.rb'

# Offense count: 2
Lint/MissingSuper:
Exclude:
- 'app/services/execute_ranked_choice_signup_service.rb'
- 'app/services/rerun_moderated_ranked_choice_signup_round_service.rb'

# Offense count: 1
Lint/NoReturnInBeginEndBlocks:
Exclude:
Expand Down Expand Up @@ -112,13 +106,18 @@ Metrics/ClassLength:
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
Metrics/CyclomaticComplexity:
Exclude:
- 'app/notifiers/notifier_preview_factory.rb'
- 'app/services/execute_ranked_choice_signup_service.rb'
- 'app/services/signup_bucket_finder.rb'

# Offense count: 1
# Configuration parameters: Max.
Metrics/ParameterLists:
Exclude:
- 'app/presenters/signup_count_presenter.rb'
- 'app/services/create_signup_request_service.rb'
- 'app/services/event_vacancy_fill_service.rb'
- 'app/services/event_withdraw_service.rb'
- 'app/services/execute_ranked_choice_signup_service.rb'

# Offense count: 1
Expand All @@ -137,6 +136,8 @@ Naming/PredicateMethod:
# Offense count: 1
Naming/PredicatePrefix:
Exclude:
- 'app/models/run.rb'
- 'app/presenters/run_availability_presenter.rb'
- 'app/presenters/signup_count_presenter.rb'

# Offense count: 1
Expand All @@ -159,6 +160,7 @@ Rails/RefuteMethods:
Rails/HasAndBelongsToMany:
Exclude:
- 'app/models/page.rb'
- 'app/models/run.rb'

Rails/HasManyOrHasOneDependent:
Exclude:
Expand All @@ -185,6 +187,9 @@ Rails/SkipsModelValidations:
Style/FrozenStringLiteralComment:
Exclude:
- 'app/models/oauth_application.rb'
- 'app/models/signup_ranked_choice.rb'
- 'app/serializers/signup_move_result_serializer.rb'
- 'app/services/create_signup_request_service.rb'
- 'app/services/event_freeze_bucket_assignments_service.rb'
- 'config/initializers/cors.rb'
- 'config/initializers/doorkeeper.rb'
Expand All @@ -193,12 +198,22 @@ Style/FrozenStringLiteralComment:
- 'test/factories/event_proposals.rb'
- 'test/factories/events.rb'
- 'test/factories/oauth_applications.rb'
- 'test/factories/signup_ranked_choices.rb'
- 'test/factories/signup_requests.rb'
- 'test/factories/signups.rb'
- 'test/liquid_drops/convention_drop_test.rb'
- 'test/liquid_drops/signup_drop_test.rb'
- 'test/liquid_drops/user_con_profile_drop_test.rb'
- 'test/models/event_proposal_test.rb'
- 'test/models/event_test.rb'
- 'test/models/registration_policy/unlimited_test.rb'
- 'test/models/registration_policy_bucket_test.rb'
- 'test/models/registration_policy_test.rb'
- 'test/models/run_test.rb'
- 'test/models/signup_change_test.rb'
- 'test/models/signup_ranked_choice_test.rb'
- 'test/models/signup_request_test.rb'
- 'test/models/signup_test.rb'
- 'test/policies/oauth_application_policy_test.rb'
- 'test/services/create_signup_request_service_test.rb'
- 'test/services/create_team_member_service_test.rb'
Expand All @@ -216,10 +231,23 @@ Layout/LineLength:

Lint/MissingSuper:
Exclude:
- 'app/liquid_drops/convention_drop.rb'
- 'app/liquid_drops/registration_policy/bucket_drop.rb'
- 'app/liquid_drops/signup_move_result_drop.rb'
- 'app/liquid_drops/signup_request_drop.rb'
- 'app/services/accept_event_proposal_service.rb'
- 'app/services/accept_signup_ranked_choice_service.rb'
- 'app/services/accept_signup_request_service.rb'
- 'app/services/create_signup_request_service.rb'
- 'app/services/create_team_member_service.rb'
- 'app/services/event_change_registration_policy_service.rb'
- 'app/services/event_freeze_bucket_assignments_service.rb'
- 'app/services/event_signup_service.rb'
- 'app/services/event_vacancy_fill_service.rb'
- 'app/services/event_withdraw_service.rb'
- 'app/services/execute_ranked_choice_signup_round_service.rb'
- 'app/services/execute_ranked_choice_signup_service.rb'
- 'app/services/rerun_moderated_ranked_choice_signup_round_service.rb'

Performance/StringInclude:
Exclude:
Expand All @@ -232,6 +260,31 @@ Rails/SquishedSQLHeredocs:
Rails/TimeZone:
Exclude:
- 'app/models/convention.rb'
- 'app/models/signup.rb'
- 'app/services/event_withdraw_service.rb'
- 'test/services/event_vacancy_fill_service_test.rb'
- 'test/services/execute_ranked_choice_signup_round_service_test.rb'

Rails/InverseOf:
Exclude:
- 'app/models/run.rb'
- 'app/models/signup.rb'

Naming/MemoizedInstanceVariableName:
Exclude:
- 'app/liquid_drops/convention_drop.rb'
- 'app/presenters/run_availability_presenter.rb'
- 'app/services/signup_bucket_finder.rb'

Lint/DuplicateBranch:
Exclude:
- 'app/presenters/signup_options_presenter.rb'

Style/MutableConstant:
Exclude:
- 'app/models/signup.rb'

Style/ReduceToHash:
Exclude:
- 'app/liquid_drops/convention_drop.rb'

2 changes: 1 addition & 1 deletion app/graphql/graphql_operations_generated.json

Large diffs are not rendered by default.

41 changes: 34 additions & 7 deletions app/graphql/mutations/create_my_signup.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
# frozen_string_literal: true
class Mutations::CreateMySignup < Mutations::BaseMutation
field :signup, Types::SignupType, null: false
description "Sign the current user up for a run, as a self-service signup"

argument :no_requested_bucket, Boolean, required: false, camelize: false
argument :requested_bucket_key, String, required: false, camelize: false
argument :run_id, ID, required: false, camelize: true
field :signup, Types::SignupType, null: false, description: "The signup that was created"

argument :no_requested_bucket,
Boolean,
required: false,
camelize: false,
description: "Set to true to sign up with no bucket preference"
argument :requested_bucket_id,
ID,
required: false,
camelize: true,
description: "The bucket to request, or null for no preference"
argument :requested_bucket_key, # rubocop:disable GraphQL/ExtractInputType
String,
required: false,
camelize: false,
deprecation_reason: "Use requestedBucketId instead",
description: "The bucket key to request, or null for no preference"
argument :run_id, # rubocop:disable GraphQL/ExtractInputType
ID,
required: false,
camelize: true,
description: "The ID of the run to sign up for"

attr_reader :run

Expand All @@ -14,8 +34,9 @@ class Mutations::CreateMySignup < Mutations::BaseMutation
end

def resolve(**args)
should_have_requested_bucket_key = args[:no_requested_bucket].blank?
if should_have_requested_bucket_key && !args[:requested_bucket_key]
should_have_requested_bucket = args[:no_requested_bucket].blank?
requested_bucket_id = args[:requested_bucket_id]&.to_i || requested_bucket_id_from_key(args)
if should_have_requested_bucket && !requested_bucket_id
raise GraphQL::ExecutionError,
"Bad request: signups must either request a bucket or specify that no bucket is requested."
end
Expand All @@ -24,7 +45,7 @@ def resolve(**args)
EventSignupService.new(
context[:user_con_profile],
run,
should_have_requested_bucket_key ? args[:requested_bucket_key] : nil,
should_have_requested_bucket ? requested_bucket_id : nil,
context[:current_user],
action: "self_service_signup"
).call_and_raise
Expand All @@ -33,4 +54,10 @@ def resolve(**args)

{ signup: result.signup }
end

private

def requested_bucket_id_from_key(args)
run.registration_policy.bucket_with_key(args[:requested_bucket_key])&.id
end
end
15 changes: 13 additions & 2 deletions app/graphql/mutations/create_signup_ranked_choice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ class Mutations::CreateSignupRankedChoice < Mutations::BaseMutation
description "The SignupRankedChoice that has been created"
end

argument :requested_bucket_key, String, required: false, camelize: false do
argument :requested_bucket_id, ID, required: false, camelize: true do
description "The bucket to queue a signup ranked choice in, or null to queue a no-preference choice"
end
argument :requested_bucket_key,
String,
required: false,
camelize: false,
deprecation_reason: "Use requestedBucketId instead" do
description "The bucket key to queue a signup ranked choice in, or null to queue a no-preference choice"
end
argument :target_run_id, ID, required: false, camelize: true do
Expand All @@ -21,11 +28,15 @@ class Mutations::CreateSignupRankedChoice < Mutations::BaseMutation
end

def resolve(**args)
requested_bucket_id =
args[:requested_bucket_id]&.to_i ||
target_run.registration_policy.bucket_with_key(args[:requested_bucket_key])&.id

signup_ranked_choice =
user_con_profile.signup_ranked_choices.create!(
state: "pending",
target_run:,
requested_bucket_key: args[:requested_bucket_key],
requested_bucket_id:,
updated_by: current_user,
priority: (user_con_profile.signup_ranked_choices.maximum(:priority) || 0) + 1
)
Expand Down
33 changes: 28 additions & 5 deletions app/graphql/mutations/create_signup_request.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
# frozen_string_literal: true
class Mutations::CreateSignupRequest < Mutations::BaseMutation
field :signup_request, Types::SignupRequestType, null: false
description "Create a request to sign up for a run, for the current user, in a moderated-signup convention"

argument :replace_signup_id, ID, required: false, camelize: true
argument :requested_bucket_key, String, required: false, camelize: false
argument :target_run_id, ID, required: false, camelize: true
field :signup_request, Types::SignupRequestType, null: false, description: "The signup request that was created"

argument :replace_signup_id,
ID,
required: false,
camelize: true,
description: "The ID of an existing signup this request should replace if accepted"
argument :requested_bucket_id,
ID,
required: false,
camelize: true,
description: "The bucket to request, or null for no preference"
argument :requested_bucket_key, # rubocop:disable GraphQL/ExtractInputType
String,
required: false,
camelize: false,
deprecation_reason: "Use requestedBucketId instead",
description: "The bucket key to request, or null for no preference"
argument :target_run_id, # rubocop:disable GraphQL/ExtractInputType
ID,
required: false,
camelize: true,
description: "The ID of the run to request a signup for"

attr_reader :target_run

Expand All @@ -15,13 +35,16 @@ class Mutations::CreateSignupRequest < Mutations::BaseMutation

def resolve(**args)
replace_signup = (user_con_profile.signups.find(args[:replace_signup_id]) if args[:replace_signup_id])
requested_bucket_id =
args[:requested_bucket_id]&.to_i ||
target_run.registration_policy.bucket_with_key(args[:requested_bucket_key])&.id

result =
CreateSignupRequestService.new(
user_con_profile:,
target_run:,
replace_signup:,
requested_bucket_key: args[:requested_bucket_key],
requested_bucket_id:,
whodunit: current_user
).call!

Expand Down
59 changes: 49 additions & 10 deletions app/graphql/mutations/create_user_signup.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,45 @@
# frozen_string_literal: true
class Mutations::CreateUserSignup < Mutations::BaseMutation
field :signup, Types::SignupType, null: false
description "Sign a user up for a run, as an admin action"

argument :no_requested_bucket, Boolean, required: false, camelize: false
argument :requested_bucket_key, String, required: false, camelize: false
argument :run_id, ID, required: false, camelize: true
argument :suppress_confirmation, Boolean, required: false, camelize: false
argument :suppress_notifications, Boolean, required: false, camelize: false
argument :user_con_profile_id, ID, required: false, camelize: true
field :signup, Types::SignupType, null: false, description: "The signup that was created"

argument :no_requested_bucket,
Boolean,
required: false,
camelize: false,
description: "Set to true to sign up with no bucket preference"
argument :requested_bucket_id,
ID,
required: false,
camelize: true,
description: "The bucket to request, or null for no preference"
argument :requested_bucket_key, # rubocop:disable GraphQL/ExtractInputType
String,
required: false,
camelize: false,
deprecation_reason: "Use requestedBucketId instead",
description: "The bucket key to request, or null for no preference"
argument :run_id, # rubocop:disable GraphQL/ExtractInputType
ID,
required: false,
camelize: true,
description: "The ID of the run to sign up for"
argument :suppress_confirmation, # rubocop:disable GraphQL/ExtractInputType
Boolean,
required: false,
camelize: false,
description: "Set to true to skip sending the signup confirmation notification"
argument :suppress_notifications, # rubocop:disable GraphQL/ExtractInputType
Boolean,
required: false,
camelize: false,
description: "Set to true to skip sending team member notifications for this signup"
argument :user_con_profile_id, # rubocop:disable GraphQL/ExtractInputType
ID,
required: false,
camelize: true,
description: "The ID of the user con profile to sign up"

attr_reader :run, :signup_user_con_profile

Expand All @@ -18,8 +50,9 @@ class Mutations::CreateUserSignup < Mutations::BaseMutation
end

def resolve(**args)
should_have_requested_bucket_key = args[:no_requested_bucket].blank?
if should_have_requested_bucket_key && !args[:requested_bucket_key]
should_have_requested_bucket = args[:no_requested_bucket].blank?
requested_bucket_id = args[:requested_bucket_id]&.to_i || requested_bucket_id_from_key(args)
if should_have_requested_bucket && !requested_bucket_id
raise GraphQL::ExecutionError,
"Bad request: signups must either request a bucket or specify that no bucket is requested."
end
Expand All @@ -28,7 +61,7 @@ def resolve(**args)
EventSignupService.new(
signup_user_con_profile,
run,
should_have_requested_bucket_key ? args[:requested_bucket_key] : nil,
should_have_requested_bucket ? requested_bucket_id : nil,
context[:current_user],
suppress_notifications: args[:suppress_notifications],
suppress_confirmation: args[:suppress_confirmation],
Expand All @@ -40,4 +73,10 @@ def resolve(**args)

{ signup: result.signup }
end

private

def requested_bucket_id_from_key(args)
run.registration_policy.bucket_with_key(args[:requested_bucket_key])&.id
end
end
Loading