Consider last-feeding-method as empty if never-changing

If the feeding method is always the same, the last-feeding-method card
is unhelpful. Consider it "empty" so it can be hidden by user setting.

This is an alternative solution to https://github.com/babybuddy/babybuddy/issues/139.
This commit is contained in:
Ohad Lutzky 2021-07-18 00:35:24 +01:00 committed by Christopher Charbonneau Wells
parent 20538ce59d
commit 9d2e539fc4
1 changed files with 2 additions and 1 deletions

View File

@ -159,7 +159,8 @@ def card_feeding_last_method(context, child):
instances = models.Feeding.objects.filter(child=child) \ instances = models.Feeding.objects.filter(child=child) \
.filter(**_filter_data_age(context)) \ .filter(**_filter_data_age(context)) \
.order_by('-end')[:3] .order_by('-end')[:3]
empty = len(instances) == 0 num_unique_methods = len({i.method for i in instances})
empty = num_unique_methods <= 1
# Results are reversed for carousel forward/back behavior. # Results are reversed for carousel forward/back behavior.
return { return {