perf: account cannot be modified (#9585)

Co-authored-by: feng <1304903146@qq.com>
pull/9586/head
fit2bot 2023-02-16 15:53:45 +08:00 committed by GitHub
parent ef33bc211d
commit b8c872c68e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 12 deletions

View File

@ -3,10 +3,10 @@ from django.utils.translation import ugettext_lazy as _
from rest_framework import status, mixins, viewsets
from rest_framework.response import Response
from accounts.models import AutomationExecution
from accounts.tasks import execute_automation
from assets import serializers
from assets.models import BaseAutomation
from accounts.tasks import execute_automation
from accounts.models import AutomationExecution
from common.const.choices import Trigger
from orgs.mixins import generics
@ -110,6 +110,6 @@ class AutomationExecutionViewSet(
serializer.is_valid(raise_exception=True)
automation = serializer.validated_data.get('automation')
task = execute_automation.delay(
pid=automation.pk, trigger=Trigger.manual, tp=self.tp
pid=str(automation.pk), trigger=Trigger.manual, tp=self.tp
)
return Response({'task': task.id}, status=status.HTTP_201_CREATED)

View File

@ -52,6 +52,8 @@ class AccountSerializerCreateValidateMixin:
return instance
def update(self, instance, validated_data):
# account cannot be modified
validated_data.pop('username', None)
push_now = validated_data.pop('push_now', None)
instance = super().update(instance, validated_data)
self.push_account(instance, push_now)

View File

@ -295,10 +295,6 @@ class DatesLoginMetricMixin:
def user_login_success_logs_amount(self):
return self.login_logs_queryset.filter(status=LoginStatusChoices.success).count()
@lazyproperty
def user_login_logs_amount(self):
return self.login_logs_queryset.values('username').count()
@lazyproperty
def user_login_amount(self):
return self.login_logs_queryset.values('username').distinct().count()
@ -383,11 +379,6 @@ class IndexApi(DateTimeMixin, DatesLoginMetricMixin, APIView):
'total_count_login_users': self.user_login_amount
})
if _all or query_params.get('total_count') or query_params.get('total_count_login_user_logs'):
data.update({
'total_count_login_user_logs': self.user_login_logs_amount
})
if _all or query_params.get('total_count') or query_params.get('total_count_today_active_assets'):
data.update({
'total_count_today_active_assets': caches.total_count_today_active_assets,