mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-11-04 14:49:58 +08:00
feat(problem tag): 支持模糊搜索
This commit is contained in:
parent
a4a66d2271
commit
515f422a2d
@ -9,7 +9,11 @@ from contest.models import ContestRuleType
|
|||||||
|
|
||||||
class ProblemTagAPI(APIView):
|
class ProblemTagAPI(APIView):
|
||||||
def get(self, request):
|
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)
|
return self.success(TagSerializer(tags, many=True).data)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user