Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- debt_import_record_system_status_qs = DebtImportRecordSystemStatus.objects.all()
- last_system_statuses_qs = debt_import_record_system_status_qs.filter(import_record_id=OuterRef('pk')).order_by('-date_created')
- all_unregistered_records_with_last_ss_qs = all_unregistered_records_qs.annotate(last_record_system_status=Subquery(last_system_statuses_qs.values('status')[:1]))
- rejected_records = all_unregistered_records_with_last_ss_qs.aggregate(
- count_records_of_rejected=Count('id', filter=Q(last_record_system_status='rejected'))
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement