fix: 修复6个P2级Bug(评分校验/合集分页/机器人健壮性/查询稳定性) - #44
Merged
Conversation
- Bug1 rate_item: score 增加 int 类型转换 try/except +
1-5 范围校验, 非法输入重定向并提示而非 500
- Bug2 collection_list: 增加 Paginator 每页 20 条,
模板增加分页导航; select_related('owner') 减少 N+1
- Bug3 collection_detail: 合集内文章增加 Paginator
每页 20 条, 模板增加分页导航
- Bug4 send_comment: Post/User 不存在时静默跳过,
避免 bot 回复已删帖子时 500
- Bug5 index 首页: Post.objects.all()[:6] 改为
order_by('-created_at')[:6], 显式排序不依赖 Meta
- Bug6 BotBase.handler: context.get(id) 改为
context.get("id"), 修复内置函数 id 导致永远返回 None
aba2222
requested changes
Aug 12, 2026
aba2222
approved these changes
Aug 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
延续 #42 (P0) 与 #43 (P1) 后的 P2 级别 Bug 修复。本 PR 聚焦输入校验、分页缺失、机器人健壮性、查询稳定性等中等优先级问题,所有修复均通过测试。
修复清单
forum/views.pyrate_itemint(score),非数字输入触发ValueError返回 500messages.error提示forum/views.pycollection_listCollection.objects.all()无分页,数据量大时单页渲染性能差Paginator每页 20 条 +select_related('owner')减少 N+1 查询forum/views.pycollection_detailPaginator每页 20 条,select_related('post', 'post__author')优化forum/bots_manager.pysend_commentPost.DoesNotExist,线程崩溃try/except捕获Post.DoesNotExist / User.DoesNotExist静默跳过forum/views.pyindexPost.objects.all()[:6]未显式排序,依赖模型 Meta,跨查询行为不稳定order_by('-created_at')[:6]显式排序forum/bots/bot.pyBotBase.handlercontext.get(id)误用内置函数id作为键,永远返回Nonecontext.get("id")模板改动
collection_list.html/collection_detail.html:新增分页导航(上一页 / 当前页/总页数 / 下一页)测试
全部 12 个测试通过。
说明