Skip to content

Fix #21: store feedback comment text and make it readable - #32

Open
xiaoyao-666-coder wants to merge 2 commits into
zhengdaodeguL:mainfrom
xiaoyao-666-coder:fix/issue-21-feedback-comments
Open

xiaoyao-666-coder wants to merge 2 commits into
zhengdaodeguL:mainfrom
xiaoyao-666-coder:fix/issue-21-feedback-comments

Conversation

@xiaoyao-666-coder

Copy link
Copy Markdown

问题

反馈 comment 文本被丢弃/存了无处可查:POST /api/feedback 接受 comment(max_length=500),但内存版只存了 hash、Redis 也只存了 hash,没有任何接口能把 comment 文本读回来。点踩写了文字也等于没写。

修复

  • 新增 GET /api/feedback/comments:与 POST 同样的鉴权、按会话归属过滤(只能读自己会话的 comment),不经过匿名的 /api/metrics。
  • 内存版:存最新 comment 文本 + 变更检测(同分换文字算一次 change 并更新文本;同分同文字不算 change)。
  • Redis:Lua 脚本现在存原始文本(≤500 字符)+ session_id/message_id/seq 字段。
  • 空白 comment 被 strip 且不计入 commented(顺带修了 round-2 的 F7)。
  • 撤销时保留 comment 文本:commented 计数是“曾经带过 comment 的消息数”,撤销 rating 不删 comment。

验证

  • 后端:MEDGUIDE_MODE=test python -m pytest -q backend/tests 531 passed(基线 521 + 10 新)。覆盖:提交后读回、改文字算 change、同文字不算 change、改票保留 comment、空白不存不计、超 500 字符 422、未登录 401、只能读自己会话的 comment、端到端 chat→反馈→读回、Redis 原子性 round-trip。
  • 前端未动。
  • 未做浏览器实点验证。

已知遗留

Closes #21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[高] 反馈 comment 文本被接受后直接丢弃,保存了也无处可查

1 participant