diff --git a/app/models/ranked_choice_decision.rb b/app/models/ranked_choice_decision.rb index c9d32c179c2..3f2fd316bd1 100644 --- a/app/models/ranked_choice_decision.rb +++ b/app/models/ranked_choice_decision.rb @@ -51,6 +51,7 @@ class RankedChoiceDecision < ApplicationRecord validates :decision, inclusion: { in: DECISIONS } validates :reason, inclusion: { in: REASONS, allow_nil: true } + validates :signup_ranked_choice, presence: { unless: ->(record) { record.decision == "skip_user" } } private diff --git a/app/presenters/tables/ranked_choice_decisions_table_results_presenter.rb b/app/presenters/tables/ranked_choice_decisions_table_results_presenter.rb index 2e730cba1e1..0e0f312509b 100644 --- a/app/presenters/tables/ranked_choice_decisions_table_results_presenter.rb +++ b/app/presenters/tables/ranked_choice_decisions_table_results_presenter.rb @@ -30,7 +30,7 @@ def generate_csv_cell(decision) ilike_column_filter :title, association_name: :event def generate_csv_cell(decision) - decision.event.title + decision.event&.title end end diff --git a/app/services/user_signup_constraints.rb b/app/services/user_signup_constraints.rb index e3bcabbe5e7..07cd5b5a5be 100644 --- a/app/services/user_signup_constraints.rb +++ b/app/services/user_signup_constraints.rb @@ -41,14 +41,14 @@ def at_maximum_signups? def concurrent_signups_for_run(run) current_signups_including_not_counted.select do |signup| other_run = signup.run - !other_run.event.can_play_concurrently? && run.overlaps?(other_run) + other_run == run || (!other_run.event.can_play_concurrently? && run.overlaps?(other_run)) end end def concurrent_signup_requests_for_run(run) pending_signup_requests_including_not_counted.select do |signup_request| other_run = signup_request.target_run - !other_run.event.can_play_concurrently? && run.overlaps?(other_run) + other_run == run || (!other_run.event.can_play_concurrently? && run.overlaps?(other_run)) end end diff --git a/db/migrate/20260409003354_make_lottery_number_index_deferrable.rb b/db/migrate/20260409003354_make_lottery_number_index_deferrable.rb new file mode 100644 index 00000000000..6272154d6fd --- /dev/null +++ b/db/migrate/20260409003354_make_lottery_number_index_deferrable.rb @@ -0,0 +1,19 @@ +class MakeLotteryNumberIndexDeferrable < ActiveRecord::Migration[8.1] + def up + remove_index :user_con_profiles, %i[convention_id lottery_number], unique: true + execute <<~SQL + ALTER TABLE user_con_profiles + ADD CONSTRAINT index_user_con_profiles_on_convention_id_and_lottery_number + UNIQUE (convention_id, lottery_number) + DEFERRABLE INITIALLY DEFERRED; + SQL + end + + def down + execute <<~SQL + ALTER TABLE user_con_profiles + DROP CONSTRAINT index_user_con_profiles_on_convention_id_and_lottery_number; + SQL + add_index :user_con_profiles, %i[convention_id lottery_number], unique: true + end +end diff --git a/db/structure.sql b/db/structure.sql index fed09025f77..ea1ac43ee32 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -3742,6 +3742,14 @@ ALTER TABLE ONLY public.forms ADD CONSTRAINT forms_pkey PRIMARY KEY (id); +-- +-- Name: user_con_profiles index_user_con_profiles_on_convention_id_and_lottery_number; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.user_con_profiles + ADD CONSTRAINT index_user_con_profiles_on_convention_id_and_lottery_number UNIQUE (convention_id, lottery_number) DEFERRABLE INITIALLY DEFERRED; + + -- -- Name: maximum_event_provided_tickets_overrides maximum_event_provided_tickets_overrides_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -5117,13 +5125,6 @@ CREATE INDEX index_user_activity_alerts_on_convention_id ON public.user_activity CREATE INDEX index_user_activity_alerts_on_user_id ON public.user_activity_alerts USING btree (user_id); --- --- Name: index_user_con_profiles_on_convention_id_and_lottery_number; Type: INDEX; Schema: public; Owner: - --- - -CREATE UNIQUE INDEX index_user_con_profiles_on_convention_id_and_lottery_number ON public.user_con_profiles USING btree (convention_id, lottery_number); - - -- -- Name: index_user_con_profiles_on_convention_id_and_user_id; Type: INDEX; Schema: public; Owner: - -- @@ -6140,6 +6141,7 @@ ALTER TABLE ONLY public.cms_files_pages SET search_path TO "$user", public; INSERT INTO "schema_migrations" (version) VALUES +('20260409003354'), ('20260321193050'), ('20260315200824'), ('20260315182359'),