Repository navigation
fix(panel): 记忆面板的「共 N 条」与分类 chip 改读服务端真分布(#597) - #630
modusensus wants to merge 1 commit into
Conversation
浏览页被 type 筛过又分了页,页内现数两头都数不出真分布: - 页头「共 N 条」用 visible.length(已加载页行数),滚动一次后恒停在 200; - 分类 chip 从已加载页现数,而页的查询串带着选中的 type——选中任一类后 其它类计数为 0 被 filter 整条滤掉,分类栏塌剩两枚、数字从 5 跳到 200。 服务端:store.count() 的 WHERE 构造抽成共用 pushCountFilters(type 刻意 不在其中),新增 countByType(opts)——同一份筛选、不带 type,一次 GROUP BY 拿全库分布;宿主内 /api/dsh-mneme/list 与 Bearer /memories 两张面同口径补 typeCounts 格(按 id 取单条的答复不带,分布无意义)。 客户端:页头 = 服务端 total(搜索态的 total 本就是命中数);chips = typeCounts 全库分布、缺类补 0;「全部」chip = 分布合计。老服务端没有 typeCounts 时退回页内现数——功能不炸,只是回到旧的「只数已加载页」行为。 test: store.test.js +1(分布合计 = count(undefined)、筛选同口径); api.test.js / standalone-api.test.js 各 +1(带 type 请求下分布仍全量); client.test.js +1 源码断言(服务端源 + 降级路径同时在)。全量 3158 用例 / 3157 通过 / 0 失败 / 1 跳过;check-sync 118 一致。
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 49 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
背景
#597(报告人给了完整对照表与建议修法,评论区复核补全了因果链):记忆面板的数字全部读错——
visible.length(已加载页行数):滚动一次后恒停在 200,库 2551 条也显示 200;client.js的filterQS),所以已加载行里只剩当前类——chips 从页内现数后其它类计数为 0,被EXPLORER_TYPES.filter((k) => counts[k])整条滤掉,分类栏塌剩「全部 + 当前类」,数字还会从 5 跳到 200。服务端的
total一直是对的(与行同口径),页面的「加载更多」按钮早就在用它——只是页头和分类栏没用。只改前端做不到:前端手上没有其它类的数字。改动
服务端(两张 HTTP 面同口径,只许剩鉴权与路径不同):
store.count()的 WHERE 构造抽成共用pushCountFilters(type 刻意不在其中——count 按调用方带、countByType 刻意不带);count()签名与行为不变;store.countByType(opts):同一份筛选、不带 type,一次GROUP BY type拿全库分布;/api/dsh-mneme/list与 Bearer/memories答复补typeCounts格(与 total 完全同一份筛选参数);按 id 取单条的答复不带这一格——分布无意义,客户端据此降级。客户端(
lib/client.js):total(搜索态的 total 本就是命中数,语义不变;browse 态不再用visible.length);typeCounts全库分布、缺类补 0——选中一类后分类栏恒定不塌;typeCounts时退回页内现数——功能不炸,只是回到旧的「只数已加载页」行为。验证
test/store.test.js+1:分布合计恒等于count(undefined)、带minImportance筛选时同口径;test/api.test.js+1 /test/standalone-api.test.js+1:带type=project请求下typeCounts仍是全量分布(其它类的数字活着的)、合计 = total;test/client.test.js+1 源码断言:服务端源、降级回退、页头 total、全部 chip 合计四处同时钉住;node --test test/*.test.js:3158 用例 / 3157 通过 / 0 失败 / 1 跳过;check-sync118 一致。不在本 PR
状态页
MemoriesStatusCard的每类一次请求(N+1)是同一痛点的另一处,可后续切到typeCounts(一张请求替代六张),CHANGELOG 里已留话头。Closes #597。