def test_stats_no_members(): from byro.members.stats import get_member_statistics member_stats = get_member_statistics() assert isinstance(member_stats, list) assert len(member_stats) == 0
def get_context_data(self, *args, **kwargs): context = super().get_context_data(*args, **kwargs) context["member_count"] = Member.objects.all().count() context["active_count"] = Member.objects.with_active_membership( ).count() context["stats"] = get_member_statistics() return context
def get_context_data(self, *args, **kwargs): context = super().get_context_data(*args, **kwargs) context['member_count'] = Member.objects.all().count() context['active_count'] = Membership.objects.filter(end__isnull=True).count() context['unmapped_transactions_count'] = RealTransaction.objects.filter(virtual_transactions__isnull=True).count() context['stats'] = get_member_statistics() return context
def get_context_data(self, *args, **kwargs): context = super().get_context_data(*args, **kwargs) context['member_count'] = Member.objects.all().count() context['active_count'] = Membership.objects.filter( Q(start__lte=now().date()) & (Q(end__isnull=True) | Q(end__gte=now().date()))).count() context['stats'] = get_member_statistics() return context
def test_stats_one_inactive_member(inactive_member): from byro.members.stats import get_member_statistics from byro.members.models import Membership assert Membership.objects.count() member_stats = get_member_statistics() assert isinstance(member_stats, list) assert len(member_stats) assert member_stats[0][1] == 1 assert member_stats[0][2] == 0 assert member_stats[-1][1] == 0 assert member_stats[-1][2] == 1 for m in member_stats[1:-1]: assert m[1] == 0 assert m[2] == 0