Repository navigation
Fix issue #6: deduct club points after booking - #5
Merged
Merged
Conversation
Reviewer's GuideUpdates the booking workflow so that, after a successful purchase, club points are reduced by the number of booked places and adds a focused test to validate this behavior using existing booking fixtures. Sequence diagram for updated booking and club points deductionsequenceDiagram
actor Secretary
participant WebApp
participant purchasePlacesRoute
participant Competition
participant Club
Secretary->>WebApp: Submit booking form
WebApp->>purchasePlacesRoute: POST /purchasePlaces
purchasePlacesRoute->>Competition: Load competition by name
purchasePlacesRoute->>Club: Load club by email
purchasePlacesRoute->>purchasePlacesRoute: Validate placesRequired <= 12
purchasePlacesRoute->>purchasePlacesRoute: Validate placesRequired <= club points
purchasePlacesRoute->>Competition: Deduct placesRequired from numberOfPlaces
purchasePlacesRoute->>Club: Deduct placesRequired from points
purchasePlacesRoute-->>WebApp: Render welcome.html with updated data
WebApp-->>Secretary: Show updated competition places and club points
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The new
test_club_points_are_deducted_after_bookingtest doesn't actually assert that the club's points were reduced (it only checks status and flash message); consider asserting the updatedclub_test["points"]to ensure the new behavior is really exercised. - In
purchasePlaces, you're convertingclub['points']tointinline for the subtraction; ifclub['points']is reused later, consider normalizing it once (e.g., when loading or before arithmetic) to avoid mixing string/int types and repeated casting.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `test_club_points_are_deducted_after_booking` test doesn't actually assert that the club's points were reduced (it only checks status and flash message); consider asserting the updated `club_test["points"]` to ensure the new behavior is really exercised.
- In `purchasePlaces`, you're converting `club['points']` to `int` inline for the subtraction; if `club['points']` is reused later, consider normalizing it once (e.g., when loading or before arithmetic) to avoid mixing string/int types and repeated casting.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request fixes the issue where club points were not deducted after a successful booking.
Previously, when a secretary booked places for a competition, the number of available places was correctly updated, but the club's points balance remained unchanged.
Now, when a booking is confirmed:
Changes made
/purchasePlacesroute to deduct booked places from the club's points balance after a valid booking.Closes #6
Summary by Sourcery
Deduct club points when places are purchased and add coverage to verify the booking flow.
Bug Fixes:
Tests: