mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-07-17 08:21:38 +00:00
perf: change secret filter
This commit is contained in:
parent
ed95a89a77
commit
7bd03c7863
@ -152,7 +152,10 @@ class ChangeSecretDashboardApi(APIView):
|
|||||||
if ongoing_counts is None:
|
if ongoing_counts is None:
|
||||||
execution_ids = []
|
execution_ids = []
|
||||||
inspect = app.control.inspect()
|
inspect = app.control.inspect()
|
||||||
active_tasks = inspect.active()
|
try:
|
||||||
|
active_tasks = inspect.active()
|
||||||
|
except Exception:
|
||||||
|
active_tasks = None
|
||||||
if active_tasks:
|
if active_tasks:
|
||||||
for tasks in active_tasks.values():
|
for tasks in active_tasks.values():
|
||||||
for task in tasks:
|
for task in tasks:
|
||||||
|
@ -192,6 +192,16 @@ class UUIDExecutionFilterMixin:
|
|||||||
|
|
||||||
class ChangeSecretRecordFilterSet(SecretRecordMixin, UUIDExecutionFilterMixin, BaseFilterSet):
|
class ChangeSecretRecordFilterSet(SecretRecordMixin, UUIDExecutionFilterMixin, BaseFilterSet):
|
||||||
execution_id = django_filters.CharFilter(method="filter_execution")
|
execution_id = django_filters.CharFilter(method="filter_execution")
|
||||||
|
days = drf_filters.NumberFilter(method="filter_days")
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def filter_days(queryset, name, value):
|
||||||
|
value = int(value)
|
||||||
|
|
||||||
|
dt = local_zero_hour()
|
||||||
|
if value != 1:
|
||||||
|
dt = local_now() - timezone.timedelta(days=value)
|
||||||
|
return queryset.filter(date_finished__gte=dt)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ChangeSecretRecord
|
model = ChangeSecretRecord
|
||||||
|
Loading…
Reference in New Issue
Block a user