refactor: real pagination for app/dataset/skill list APIs - #7451
Closed
ctlaltlaltc wants to merge 1 commit into
Closed
refactor: real pagination for app/dataset/skill list APIs#7451ctlaltlaltc wants to merge 1 commit into
ctlaltlaltc wants to merge 1 commit into
Conversation
Coverage Report
File CoverageNo changed files found. |
|
✅ Admin Preview Image Ready! 🕒 Time: 2026-08-07 16:05:30 (UTC+8) |
|
✅ Docs Preview Deployed! 🔗 👀 Click here to visit preview 🕒 Time: 2026-08-05 17:44:14 (UTC+8) |
|
✅ Build Successful - Preview fastgpt Image for this PR: 🕒 Time: 2026-08-07 16:08:04 (UTC+8) |
ctlaltlaltc
marked this pull request as draft
August 5, 2026 01:22
ctlaltlaltc
force-pushed
the
refactor/list-api-pagination
branch
from
August 5, 2026 01:53
26e2b4e to
871b891
Compare
ctlaltlaltc
marked this pull request as ready for review
August 5, 2026 01:53
ctlaltlaltc
marked this pull request as draft
August 5, 2026 08:37
ctlaltlaltc
force-pushed
the
refactor/list-api-pagination
branch
from
August 5, 2026 09:41
7f06959 to
9dd1950
Compare
ctlaltlaltc
marked this pull request as ready for review
August 5, 2026 09:42
ctlaltlaltc
marked this pull request as draft
August 6, 2026 01:31
ctlaltlaltc
force-pushed
the
refactor/list-api-pagination
branch
2 times, most recently
from
August 7, 2026 07:48
4e11578 to
366a970
Compare
ctlaltlaltc
force-pushed
the
refactor/list-api-pagination
branch
from
August 7, 2026 07:56
366a970 to
5c38641
Compare
ctlaltlaltc
marked this pull request as ready for review
August 7, 2026 08:25
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.
背景与问题
/core/app/list、/core/dataset/list、/core/ai/skill/list三个核心资源列表接口是伪分页:DB 层全量 find(无 skip/limit),分页(如果有)在内存 slice 完成;且最终可见集合依赖内存权限计算(tmb 直授 + 成员组/组织展开 + 目录 inheritPermission 继承 + hasReadPer 过滤),countDocuments 无法直接对「权限过滤后」的集合计数。方案简述
getMyResourcePermission复用现有权限拉取 + 组/组织展开,新增readableDirectIds(按资源聚合角色位tmbRole ?? groupAndOrgRole,复用对应 Permission 类判定 read 位),纯内存可计算量;$or: [{_id ∈ readableDirectIds}, {tmbId}(创建者), {type ∉ folder, inheritPermission, parentId ∈ readableDirectIds}(一层继承)]—— 由位运算分配律证明与内存过滤逐条等价(继承判定中父权限为直接权限、非递归,无需 $graphLookup);find(match).sort({updateTime:-1,_id:-1}).skip(offset).limit(pageSize)与countDocuments(match)并行,同一 match 常量 + 同一读偏好,total == 权限过滤后可见集合数量,杜绝计数漂移;parseV2Pagination解析(?? 语义正确处理 offset=0);向后兼容
POST /core/{app,dataset,ai/skill}/listV2,返回{list, total},前端迁移字段形状零适配;验证与测试工作
自动化测试(53 个全部通过):
端到端验证(chrome-devtools 驱动真实浏览器):