mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-04-27 19:17:01 +00:00
perf: gather account node_id filter
This commit is contained in:
parent
94a8122eac
commit
042c3d1ba8
@ -9,7 +9,7 @@ from rest_framework.response import Response
|
||||
|
||||
from accounts import serializers
|
||||
from accounts.const import AutomationTypes
|
||||
from accounts.filters import GatheredAccountFilterSet
|
||||
from accounts.filters import GatheredAccountFilterSet, NodeFilterBackend
|
||||
from accounts.models import GatherAccountsAutomation, AutomationExecution, Account
|
||||
from accounts.models import GatheredAccount
|
||||
from assets.models import Asset
|
||||
@ -76,6 +76,7 @@ class GatheredAccountViewSet(OrgBulkModelViewSet):
|
||||
model = GatheredAccount
|
||||
search_fields = ("username",)
|
||||
filterset_class = GatheredAccountFilterSet
|
||||
extra_filter_backends = [NodeFilterBackend]
|
||||
ordering = ("status",)
|
||||
serializer_classes = {
|
||||
"default": serializers.DiscoverAccountSerializer,
|
||||
|
@ -143,17 +143,12 @@ class AccountFilterSet(BaseFilterSet):
|
||||
|
||||
|
||||
class GatheredAccountFilterSet(BaseFilterSet):
|
||||
node_id = drf_filters.CharFilter(method="filter_nodes")
|
||||
asset_id = drf_filters.CharFilter(field_name="asset_id", lookup_expr="exact")
|
||||
asset_name = drf_filters.CharFilter(
|
||||
field_name="asset__name", lookup_expr="icontains"
|
||||
)
|
||||
status = drf_filters.CharFilter(field_name="status", lookup_expr="exact")
|
||||
|
||||
@staticmethod
|
||||
def filter_nodes(queryset, name, value):
|
||||
return AccountFilterSet.filter_nodes(queryset, name, value)
|
||||
|
||||
class Meta:
|
||||
model = GatheredAccount
|
||||
fields = ["id", "username"]
|
||||
|
Loading…
Reference in New Issue
Block a user