From 515f422a2d056bbe879b0b6135548d694f28084c Mon Sep 17 00:00:00 2001 From: helsonxiao Date: Sun, 29 Nov 2020 14:01:12 +0800 Subject: [PATCH] =?UTF-8?q?feat(problem=20tag):=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=A8=A1=E7=B3=8A=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problem/views/oj.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/problem/views/oj.py b/problem/views/oj.py index b091ff3..3d3c443 100644 --- a/problem/views/oj.py +++ b/problem/views/oj.py @@ -9,7 +9,11 @@ from contest.models import ContestRuleType class ProblemTagAPI(APIView): def get(self, request): - tags = ProblemTag.objects.annotate(problem_count=Count("problem")).filter(problem_count__gt=0) + qs = ProblemTag.objects + keyword = request.GET.get('keyword') + if keyword: + qs = ProblemTag.objects.filter(name__icontains=keyword) + tags = qs.annotate(problem_count=Count("problem")).filter(problem_count__gt=0) return self.success(TagSerializer(tags, many=True).data)