feat: 优化mlogbw bulk update
This commit is contained in:
parent
c7514836cb
commit
fa7d3095de
|
@ -961,9 +961,20 @@ class MlogbwViewSet(CustomModelViewSet):
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def perform_update(self, serializer):
|
def perform_update(self, serializer):
|
||||||
mlogbw = serializer.save()
|
mlogbw = serializer.save()
|
||||||
Mlogbw.cal_count_notok(mlogbw.mlogb)
|
if isinstance(mlogbw, list):
|
||||||
mlog = mlogbw.mlogb.mlog
|
pass
|
||||||
mlog.cal_mlog_count_from_mlogb()
|
else:
|
||||||
|
Mlogbw.cal_count_notok(mlogbw.mlogb)
|
||||||
|
mlog = mlogbw.mlogb.mlog
|
||||||
|
mlog.cal_mlog_count_from_mlogb()
|
||||||
|
|
||||||
|
def after_bulk_update(self, objs):
|
||||||
|
mlogbIds = list(set([obj.mlogb for obj in objs]))
|
||||||
|
for mlogbId in mlogbIds:
|
||||||
|
mlogbw = Mlogbw.objects.get(id=mlogbId)
|
||||||
|
Mlogbw.cal_count_notok(mlogbw.mlogb)
|
||||||
|
mlog = mlogbw.mlogb.mlog
|
||||||
|
mlog.cal_mlog_count_from_mlogb()
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def perform_destroy(self, instance:Mlogbw):
|
def perform_destroy(self, instance:Mlogbw):
|
||||||
|
|
Loading…
Reference in New Issue