Skip to content

Commit

Permalink
Optimize Checkout Page One READ queries (#1021)
Browse files Browse the repository at this point in the history
* remove unneeded local variable from TickeTier.tickets_sold_count, return .count() directly

* use .tickets_available in .tickets_sold_minus_available calculation

* Fix copy on joined waitlist template

---------

Co-authored-by: Tahmid Khan <[email protected]>
  • Loading branch information
crypto-rizzo and halfmoonui authored Feb 13, 2024
1 parent 584be88 commit eeeda23
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions backend/apps/root/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ def clean(self, *args, **kwargs):
raise GoogleWalletAPIRequestError(
"Something went wrong while handling the Google event class."
)

return super().clean(*args, **kwargs)

def transition_draft(self, save=True):
Expand Down Expand Up @@ -966,13 +966,11 @@ def generate_tx_type(self):

@cached_property
def tickets_sold_count(self):
tickets = Ticket.objects.filter(ticket_tier=self)
return tickets.count()
return Ticket.objects.filter(ticket_tier=self).count()

@cached_property
def tickets_available(self):
tickets = Ticket.objects.filter(ticket_tier=self)
return self.capacity - tickets.count()
return self.capacity - self.tickets_sold_count

@cached_property
def tickets_sold_exceeding_capacity(self):
Expand Down
4 changes: 2 additions & 2 deletions backend/templates/checkout/joined_waiting_queue.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ <h3>
<span class="text-success-emphasis me-1">
<i class="fa-light fa-check"></i>
</span>
{% trans "Joined Waiting Queue" %}
{% trans "Joined Waitlist" %}
</h3>
<p>
{% trans "You have successfully joined the waiting queue for this event. If the organizer decides, you'll be sent an email, so please be on the lookout for that." %}
{% trans "You have successfully joined the waitlist. The event organizer reviews all submissions, and if selected, you will receive your tickets." %}
</p>
<div>
<a href="{% url 'checkout:checkout_one' object.event.team.slug object.event.slug %}?checkout_type={{ object.tx_type }}&name={{ object.name }}&email={{ object.email }}">
Expand Down

0 comments on commit eeeda23

Please sign in to comment.