From f390556a874457100b8d48a384de1943023389f7 Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 18 Aug 2021 14:38:35 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96spm=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/common/drf/filters.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/common/drf/filters.py b/apps/common/drf/filters.py index c2fd94e3f..1c89f49ac 100644 --- a/apps/common/drf/filters.py +++ b/apps/common/drf/filters.py @@ -110,8 +110,11 @@ class IDSpmFilter(filters.BaseFilterBackend): return queryset cache_key = const.KEY_CACHE_RESOURCE_IDS.format(spm) resource_ids = cache.get(cache_key) - if resource_ids is None or not isinstance(resource_ids, list): - return queryset + + if resource_ids is None: + return queryset.none() + if isinstance(resource_ids, str): + resource_ids = [resource_ids] if hasattr(view, 'filter_spm_queryset'): queryset = view.filter_spm_queryset(resource_ids, queryset) else: