From 5df6361dee3a1e6c6dead4777e25b976bb3486e8 Mon Sep 17 00:00:00 2001 From: vapao Date: Tue, 15 Sep 2020 09:54:26 +0800 Subject: [PATCH] =?UTF-8?q?U=20=E4=BC=98=E5=8C=96=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spug_api/apps/deploy/views.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/spug_api/apps/deploy/views.py b/spug_api/apps/deploy/views.py index 81fa4e6..10941da 100644 --- a/spug_api/apps/deploy/views.py +++ b/spug_api/apps/deploy/views.py @@ -130,6 +130,7 @@ class RequestView(View): Argument('count', type=int, required=False, help='请输入数字') ).parse(request.GET) if error is None: + rds = get_redis_connection() if form.id: DeployRequest.objects.filter(pk=form.id, status__in=('0', '1', '-1')).delete() return json_response() @@ -143,9 +144,15 @@ class RequestView(View): else: counter[item.deploy_id] += 1 count, _ = DeployRequest.objects.filter(id__in=ids).delete() + if ids: + rds.delete(*(f'{settings.REQUEST_KEY}:{x}' for x in ids)) return json_response(count) elif form.expire: - count, _ = DeployRequest.objects.filter(created_at__lt=form.expire).delete() + requests = DeployRequest.objects.filter(created_at__lt=form.expire) + ids = [x.id for x in requests] + count, _ = requests.delete() + if ids: + rds.delete(*(f'{settings.REQUEST_KEY}:{x}' for x in ids)) return json_response(count) else: return json_response(error='请至少使用一个删除条件')