Skip to content

Commit c705047

Browse files
authored
Merge pull request #10944 from neinteractiveliterature/nbudin/issue10084
"random game" end of queue option
2 parents 693d55f + b1cfe5c commit c705047

23 files changed

Lines changed: 394 additions & 164 deletions

app/graphql/graphql_operations_generated.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Types::RankedChoiceFallbackAction < Types::BaseEnum
2+
description "An action to take if a user can't be signed up for any of their ranked choices during a signup round"
3+
4+
UserConProfile.ranked_choice_fallback_actions.each_value { |enum_value| value enum_value.upcase, value: enum_value }
5+
end

app/graphql/types/user_con_profile_input_type.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ class Types::UserConProfileInputType < Types::BaseInputObject
3535
argument :preferred_contact, String, required: false, camelize: false do
3636
description "The method by which this user profile prefers the convention contact them."
3737
end
38-
argument :ranked_choice_allow_waitlist, Boolean, required: false, camelize: false do
39-
description "If this user can't be signed up for any of their ranked choices, should the site waitlist them?"
38+
argument :ranked_choice_fallback_action, Types::RankedChoiceFallbackAction, required: false, camelize: false do
39+
description "If this user can't be signed up for any of their ranked choices, what should the site do?"
4040
end
4141
argument :show_nickname_in_bio, Boolean, required: false, camelize: false do
4242
description "Should this profile's bio use the nickname as part of their name?"

app/graphql/types/user_con_profile_type.rb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,15 @@ def self.personal_info_field(field_name, ...)
5656
field :nickname, String, null: true, description: "This user profile's nickname."
5757
field :order_summary, String, null: false, description: "A human-readable summary of all this profile's orders."
5858
field :orders, [Types::OrderType], null: false, description: "All the orders placed by this profile."
59-
field :ranked_choice_allow_waitlist, Boolean, null: false do
59+
field :ranked_choice_allow_waitlist,
60+
Boolean,
61+
null: false,
62+
deprecation_reason: "Use ranked_choice_fallback_action instead" do
6063
description "If this user can't be signed up for any of their ranked choices, should the site waitlist them?"
6164
end
65+
field :ranked_choice_fallback_action, Types::RankedChoiceFallbackAction, null: false do
66+
description "If this user can't be signed up for any of their ranked choices, what should the site do?"
67+
end
6268
field :ranked_choice_user_constraints, [Types::RankedChoiceUserConstraintType], null: false do # rubocop:disable GraphQL/ExtractType
6369
description "All the constraints this profile has placed on the number of ranked choice signups they want."
6470
end
@@ -116,7 +122,7 @@ def self.personal_info_field(field_name, ...)
116122
personal_info_field :user, Types::UserType, null: true, description: "The user account attached to this profile."
117123
personal_info_field :zipcode, String, null: true, description: "The ZIP portion of this profile's mailing address."
118124

119-
def site_admin
125+
def site_admin # rubocop:disable Naming/PredicateMethod
120126
dataloader.with(Sources::ActiveRecordAssociation, UserConProfile, :user).load(object).site_admin?
121127
end
122128

@@ -198,7 +204,7 @@ def order_summary
198204
dataloader.with(Sources::OrderSummary).load(object)
199205
end
200206

201-
def can_override_maximum_event_provided_tickets
207+
def can_override_maximum_event_provided_tickets # rubocop:disable Naming/PredicateMethod
202208
user = object == context[:user_con_profile] ? pundit_user : AuthorizationInfo.new(object.user, nil)
203209

204210
override = context[:convention].ticket_types.new.maximum_event_provided_tickets_overrides.new
@@ -210,6 +216,10 @@ def ticket
210216
ticket && policy(ticket).read? ? ticket : nil
211217
end
212218

219+
def ranked_choice_allow_waitlist # rubocop:disable Naming/PredicateMethod
220+
object.ranked_choice_fallback_action == "waitlist"
221+
end
222+
213223
private
214224

215225
# Not exposed as a field, but needed by FormResponseAttrsFields

app/javascript/EventsApp/MySignupQueue/RankedChoiceUserSettings.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next';
77
import { useAppDateTimeFormat } from '../../TimeUtils';
88
import { DateTime } from 'luxon';
99
import Timespan from '../../Timespan';
10-
import { RankedChoiceUserConstraint, SignupState } from '../../graphqlTypes.generated';
10+
import { RankedChoiceFallbackAction, RankedChoiceUserConstraint, SignupState } from '../../graphqlTypes.generated';
1111
import BucketAvailabilityDisplay from '../EventPage/BucketAvailabilityDisplay';
1212
import { useMutation } from '@apollo/client';
1313
import { UpdateUserConProfileDocument } from '../../UserConProfiles/mutations.generated';
@@ -224,21 +224,22 @@ function RankedChoiceUserSettings({ data }: { data: MySignupQueueQueryData }) {
224224
<div className="card-header">{t('signups.mySignupQueue.settingsSection.label')}</div>
225225
<div className="card-body">
226226
<MultipleChoiceInput
227-
caption={t('signups.mySignupQueue.allowWaitlist.caption')}
227+
caption={t('signups.mySignupQueue.fallbackAction.caption')}
228228
choices={[
229-
{
230-
label: t('signups.mySignupQueue.allowWaitlist.yes'),
231-
value: 'true',
232-
},
233-
{ label: t('signups.mySignupQueue.allowWaitlist.no'), value: 'false' },
234-
]}
235-
value={(data.convention.my_profile?.ranked_choice_allow_waitlist || false).toString()}
229+
RankedChoiceFallbackAction.Waitlist,
230+
RankedChoiceFallbackAction.RandomSignup,
231+
RankedChoiceFallbackAction.None,
232+
].map((value) => ({
233+
label: t(`signups.mySignupQueue.fallbackAction.${value}`),
234+
value,
235+
}))}
236+
value={data.convention.my_profile?.ranked_choice_fallback_action}
236237
onChange={async (newValue) => {
237238
await updateUserConProfile({
238239
variables: {
239240
input: {
240241
user_con_profile: {
241-
ranked_choice_allow_waitlist: newValue === 'true',
242+
ranked_choice_fallback_action: newValue as RankedChoiceFallbackAction,
242243
},
243244
id: myProfile?.id,
244245
},

app/javascript/EventsApp/MySignupQueue/SignupQueueMessages.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RankedChoiceDecisionReason, SignupState } from 'graphqlTypes.generated';
1+
import { RankedChoiceDecisionReason, RankedChoiceFallbackAction, SignupState } from 'graphqlTypes.generated';
22
import { DateTime } from 'luxon';
33
import { Trans, useTranslation } from 'react-i18next';
44
import { formatLCM, getDateTimeFormat } from 'TimeUtils';
@@ -80,7 +80,7 @@ export function SkipReason({ pendingChoice, simulatedSkipReason, userConProfile
8080
</>
8181
);
8282
} else if (simulatedSkipReason.reason === RankedChoiceDecisionReason.Full) {
83-
if (userConProfile.ranked_choice_allow_waitlist) {
83+
if (userConProfile.ranked_choice_fallback_action === RankedChoiceFallbackAction.Waitlist) {
8484
if (pendingChoice.prioritize_waitlist) {
8585
return (
8686
<>

app/javascript/EventsApp/MySignupQueue/UserSignupQueueItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
UpdateSignupRankedChoicePriorityDocument,
77
} from './mutations.generated';
88
import { Link, useRevalidator } from 'react-router';
9-
import { RankedChoiceDecisionReason } from 'graphqlTypes.generated';
9+
import { RankedChoiceDecisionReason, RankedChoiceFallbackAction } from 'graphqlTypes.generated';
1010
import { ReactNode, useContext, useRef, useState } from 'react';
1111
import { flushSync } from 'react-dom';
1212
import RankedChoicePriorityIndicator from './RankedChoicePriorityIndicator';
@@ -90,7 +90,7 @@ export default function UserSignupQueueItem({
9090
[styles.skip]: pendingChoice.simulated_skip_reason,
9191
[styles.waitlist]:
9292
pendingChoice.simulated_skip_reason?.reason === RankedChoiceDecisionReason.Full &&
93-
userConProfile.ranked_choice_allow_waitlist,
93+
userConProfile.ranked_choice_fallback_action === RankedChoiceFallbackAction.Waitlist,
9494
})}
9595
style={{
9696
// @ts-expect-error awaiting fix for https://github.com/frenic/csstype/issues/193

app/javascript/EventsApp/MySignupQueue/queries.generated.ts

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

app/javascript/EventsApp/MySignupQueue/queries.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fragment RankedChoiceUserConstraintFields on RankedChoiceUserConstraint {
77

88
fragment UserConProfileRankedChoiceQueueFields on UserConProfile {
99
id
10-
ranked_choice_allow_waitlist
10+
ranked_choice_fallback_action
1111

1212
ranked_choice_user_constraints {
1313
id

app/javascript/SignupModeration/queries.generated.ts

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)