rancher service & quota usage service
This commit is contained in:
13
apps/herd/services/rancher_service.py
Normal file
13
apps/herd/services/rancher_service.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from django.db.models import Sum, functions, Value
|
||||
|
||||
|
||||
class RancherService:
|
||||
|
||||
@staticmethod
|
||||
def get_total_used_weight(rancher, sale_item):
|
||||
return sale_item.objects.filter(
|
||||
transaction__rancher=rancher,
|
||||
transaction__transaction_status='success'
|
||||
).aggregate(
|
||||
total_weight=functions.Coalesce(Sum('weight'), Value(0))
|
||||
)['total_weight']
|
||||
Reference in New Issue
Block a user