style: ruff format 全仓库
行宽 180 下把历史遗留的折行表达式合并,无语义改动。 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -43,5 +43,3 @@ class Comment(models.Model):
|
||||
indexes = [
|
||||
models.Index(fields=["problem", "create_time"], name="comment_problem_time_idx"),
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -28,4 +28,4 @@ class CommentListSerializer(serializers.ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = Comment
|
||||
fields = "__all__"
|
||||
fields = "__all__"
|
||||
|
||||
@@ -17,9 +17,7 @@ class CommentAPI(APIView):
|
||||
except Problem.DoesNotExist:
|
||||
return self.error("Problem doesn't exist")
|
||||
comments = comments.filter(problem=problem)
|
||||
return self.success(
|
||||
self.paginate_data(request, comments, CommentListSerializer)
|
||||
)
|
||||
return self.success(self.paginate_data(request, comments, CommentListSerializer))
|
||||
|
||||
@super_admin_required
|
||||
def delete(self, request):
|
||||
|
||||
@@ -54,11 +54,7 @@ class CommentAPI(AsyncAPIView):
|
||||
@login_required
|
||||
async def get(self, request):
|
||||
problem_id = request.GET.get("problem_id")
|
||||
comment = await (
|
||||
Comment.objects.select_related("problem")
|
||||
.filter(user=request.user, problem_id=problem_id)
|
||||
.afirst()
|
||||
)
|
||||
comment = await Comment.objects.select_related("problem").filter(user=request.user, problem_id=problem_id).afirst()
|
||||
if comment:
|
||||
return self.success(await self.async_serialize_data(CommentSerializer, comment))
|
||||
else:
|
||||
@@ -82,10 +78,13 @@ class CommentStatisticsAPI(AsyncAPIView):
|
||||
if not agg["count"]:
|
||||
return self.success()
|
||||
|
||||
data = {"count": agg["count"], "rating": {
|
||||
"description": agg["description"],
|
||||
"difficulty": agg["difficulty"],
|
||||
"comprehensive": agg["comprehensive"],
|
||||
}}
|
||||
data = {
|
||||
"count": agg["count"],
|
||||
"rating": {
|
||||
"description": agg["description"],
|
||||
"difficulty": agg["difficulty"],
|
||||
"comprehensive": agg["comprehensive"],
|
||||
},
|
||||
}
|
||||
await async_cache_set(cache_key, data, 3600)
|
||||
return self.success(data)
|
||||
|
||||
Reference in New Issue
Block a user