Skip to content

Commit

Permalink
Fixes issue 108 - additional filter on tended drinks (#109)
Browse files Browse the repository at this point in the history
* Adds an additional filter for tended drinks to exclude drinks without a DCF, transactions, and kegs.

* Added distinct to query

---------

Co-authored-by: Frank van Mourik <[email protected]>
  • Loading branch information
FrankvanMourik and Frank van Mourik authored May 8, 2023
1 parent 00236ea commit 6ca034f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion alexia/apps/organization/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from django.conf import settings
from django.db import models
from django.db.models import Q
from django.urls import reverse
from django.utils import timezone
from django.utils.encoding import python_2_unicode_compatible
Expand Down Expand Up @@ -114,10 +115,12 @@ def has_iva(self):

def tended_count(self):
return BartenderAvailability.objects.filter(
Q(event__kegs__gt=0) | Q(event__consumptionform__isnull=False) | Q(event__orders=True) |
Q(event__ends_at__lte=timezone.datetime(2016, 12, 13)), # Date of first consumption form
user=self.user,
event__ends_at__lte=timezone.now(),
availability__nature=Availability.ASSIGNED,
).count()
).distinct().count()

def get_bartender_name(self):
return (self.nickname or self.user.first_name)
Expand Down

0 comments on commit 6ca034f

Please sign in to comment.