You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

31 lines
999 B

# coding=utf-8
import os
import django
import sys
sys.path.append("/var/www/skillbox/")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lms.settings")
django.setup()
from finance.models import Bill
from django.db.models import Q
packs = [67, 66, 64, 65, 68, 69]
print('## Скольким пользователям было продано более, чем 1 курс. Исключая пакеты.')
print('Всего оплаченых счетов: {0}'.format(Bill.objects.filter(status='F', user__in_role='U').exclude(Q(service__id__in=packs) |
Q(service__course=None)).count()))
_u = {}
for _b in Bill.objects.filter(status='F', user__in_role='U').exclude(service__id__in=packs):
if _u.get(_b.user.email):
_u[_b.user.email] += 1
else:
_u[_b.user.email] = 1
_c = 0
for k, v in _u.items():
if v > 1:
_c += 1
print('Повторных счетов: {0}'.format(_c))