Skip to content

Fix: Workshop capacity checks now properly compare attending count with available spaces#2609

Merged
mroderick merged 1 commit intocodebar:masterfrom
mroderick:fix/workshop-capacity-checks
May 6, 2026
Merged

Fix: Workshop capacity checks now properly compare attending count with available spaces#2609
mroderick merged 1 commit intocodebar:masterfrom
mroderick:fix/workshop-capacity-checks

Conversation

@mroderick
Copy link
Copy Markdown
Collaborator

This PR fixes a bug introduced in #2605 where workshop capacity checks were not working correctly.

Problem

PR #2605 changed the capacity check methods from student_spaces?/coach_spaces? to event_student_spaces?/event_coach_spaces?, but the new methods inherited from EventPresenter called model.student_spaces? which just checks if the attribute is present (truthy), not if spaces are actually available.

This caused workshops to incorrectly show as full when spaces were available, and vice versa.

Solution

Added proper event_student_spaces? and event_coach_spaces? methods to WorkshopPresenter that correctly compare the number of attending students/coaches with the available spaces:

def event_student_spaces?
  model.student_spaces > attending_students.length
end

def event_coach_spaces?
  model.coach_spaces > attending_coaches.length
end

Key Fix

Uses model.student_spaces (the database column) instead of student_spaces (the presenter method that delegates to venue.seats). This ensures that when tests or admins set workshop.student_spaces = 0, the capacity check respects that value rather than reading from the venue.

Testing

  • Added spec/presenters/workshop_presenter_capacity_spec.rb with 4 test cases
  • All 43 related invitation tests pass
  • All 81 presenter tests pass

Bug Report Context

From Slack:

An error has popped up, I'm not sure if it's all workshops or just the latest Barcelona one. But invites have gone out and on the invitation page it says the workshop is full. When I then try to RSVP it adds me to waitilist even though all students spots are still available

I just tried it out on the latest virtual UK workshop and it seemed to work fine. The Berlin one though is broken and doing the same as Barcelona

…th available spaces

PR codebar#2605 changed the capacity check methods from student_spaces?/
coach_spaces? to event_student_spaces?/event_coach_spaces?, but the
new methods in EventPresenter called model.student_spaces? which just
checks if the attribute is present (truthy), not if spaces are actually
available.

This fix adds proper event_student_spaces? and event_coach_spaces?
methods to WorkshopPresenter that correctly compare the number of
attending students/coaches with the available spaces from the workshop
model (using model.student_spaces and model.coach_spaces).

This ensures that:
- When 2 students attend a workshop with 2 spaces, event_student_spaces?
  returns false (correctly indicating the workshop is full)
- When 1 student attends a workshop with 2 spaces, event_student_spaces?
  returns true (correctly indicating space is available)

Fixes the bug where workshops showed as full even when spaces were
available, and vice versa.
@mroderick mroderick marked this pull request as ready for review May 6, 2026 10:30
@mroderick mroderick requested a review from KimberleyCook May 6, 2026 10:30
Copy link
Copy Markdown
Contributor

@KimberleyCook KimberleyCook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow!! That was quick 🚀

@mroderick mroderick merged commit b381129 into codebar:master May 6, 2026
14 of 15 checks passed
mroderick added a commit that referenced this pull request May 6, 2026
PR #2609 changed WorkshopPresenter to use model.student_spaces and
model.coach_spaces for capacity checks, but this broke in-person
workshops that rely on sponsor capacity.

Most in-person workshops have student_spaces=0 and coach_spaces=0 in
the database, with actual capacity coming from the sponsor/venue.

This fix changes event_student_spaces? and event_coach_spaces? to use
the presenter methods student_spaces and coach_spaces, which delegate
to the sponsor for in-person workshops.

- In-person workshops: use venue.seats and venue.coach_spots
- Virtual workshops: use model.student_spaces and model.coach_spaces

Fixes: Workshops incorrectly showing as full when sponsor has capacity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants