mirror of https://github.com/jumpserver/jumpserver
perf: change secret filter
parent
f4fa153ffa
commit
c40275d0ec
|
@ -152,7 +152,10 @@ class ChangeSecretDashboardApi(APIView):
|
|||
if ongoing_counts is None:
|
||||
execution_ids = []
|
||||
inspect = app.control.inspect()
|
||||
active_tasks = inspect.active()
|
||||
try:
|
||||
active_tasks = inspect.active()
|
||||
except Exception:
|
||||
active_tasks = None
|
||||
if active_tasks:
|
||||
for tasks in active_tasks.values():
|
||||
for task in tasks:
|
||||
|
|
|
@ -192,6 +192,16 @@ class UUIDExecutionFilterMixin:
|
|||
|
||||
class ChangeSecretRecordFilterSet(SecretRecordMixin, UUIDExecutionFilterMixin, BaseFilterSet):
|
||||
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:
|
||||
model = ChangeSecretRecord
|
||||
|
|
Loading…
Reference in New Issue