Skip to content

refactor(chat): push pagination down to ListByOwnerIDs - #20450

Merged
wangq8 merged 1 commit into
infiniflow:mainfrom
flyingwhit:refactor/push-chat-pagination-down
Sep 30, 2026
Merged

wangq8 merged 1 commit into
infiniflow:mainfrom
flyingwhit:refactor/push-chat-pagination-down

Conversation

@flyingwhit

Copy link
Copy Markdown
Contributor

Summary

This PR pushes pagination down to the DAO layer. Replaces in-memory counting with database-level COUNT and LIMIT/OFFSET, reducing memory usage and improving performance on large datasets. Verified via unit tests and manual pagination checks.

@flyingwhit
flyingwhit requested a review from wangq8 September 30, 2026 06:47
@flyingwhit flyingwhit added the ci Continue Integration label Sep 30, 2026
@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 5fe0e144-de6b-4309-aa6f-16bda3e6c55d

📥 Commits

Reviewing files that changed from the base of the PR and between 69ff9a9 and ebae4d6.

📒 Files selected for processing (4)
  • internal/dao/chat.go
  • internal/dao/chat_test.go
  • internal/service/chat.go
  • internal/service/chat_list_test.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Owner-ID chat listing now accepts pagination in the DAO. The DAO counts matching rows and applies SQL offset and limit when both pagination values are positive. The service passes pagination parameters through instead of slicing returned rows. Tests cover page boundaries, totals, unpaginated results, and joined owner fields.

Changes

Owner-ID Chat Pagination

Layer / File(s) Summary
DAO pagination and query tests
internal/dao/chat.go, internal/dao/chat_test.go
ListByOwnerIDs accepts page parameters, counts matching rows, and applies offset and limit to paginated queries. Tests check page boundaries, totals, and joined owner fields.
Service pagination integration
internal/service/chat.go, internal/service/chat_list_test.go
ListChats passes page parameters to the DAO instead of slicing returned rows. Tests check paginated and unpaginated owner-ID requests.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Suggested reviewers: marmar9615-cloud

Merge Risk: ⚪ Minimal · up to ebae4

Owner-ID chat pagination now runs in the database while preserving totals and returned fields. No actionable merge-blocking risk is identified; merge after normal checks pass.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: moving pagination into ListByOwnerIDs.
Description check ✅ Passed The description includes the required Summary section and explains the purpose, implementation, performance benefits, and verification steps.
Docstring Coverage ✅ Passed Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 4 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

A rabbit counts the rows in line
Then asks the page-sized list to shine
The service sends the page along
The owner names stay joined and strong
Five chats bound through tests with care
And every page finds its share

Comment @coderabbitai help to get the list of available commands.

@wangq8
wangq8 requested a review from buua436 September 30, 2026 11:31
@wangq8
wangq8 merged commit 5bb8171 into infiniflow:main Sep 30, 2026
6 checks passed
MarMarLabs added a commit to MarMarLabs/ragflow that referenced this pull request Sep 30, 2026
infiniflow#20450 moved pagination for the owner_ids branch into ListByOwnerIDs, so
the DAO now takes page and pageSize and the service no longer slices the
rows itself. This branch adds exact id and name filters to the same
function, so the two signatures conflicted.

ListByOwnerIDs keeps both: page and pageSize from infiniflow#20450, then keywords,
id and name. The id and name predicates are applied before the COUNT, so
the total infiniflow#20450 reports still follows the filtered rows. The service
call passes both.

Both sides added tests to internal/dao/chat_test.go and
internal/service/chat_list_test.go, and all of them are kept. The new
pagination tests from infiniflow#20450 pass empty id and name, and the exact filter
tests from this branch pass page 1 and size 10 to the owner branch. No
assertion changed on either side.

internal/dao 267, internal/service 1195 and internal/handler 585 tests
pass with no failures, including the four tests the two sides added. go
vet and gofmt are clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants