You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@answer.apache.org by "lhk0504 (via GitHub)" <gi...@apache.org> on 2026/10/20 12:22:01 UTC
[PR] fix: filter personal comment targets before pagination [answer]
lhk0504 opened a new pull request, #1649:
URL: https://github.com/apache/answer/pull/1649
Fixes #1645
## Proposed Changes
- Resolve the distinct targets of a user's available comments and reuse `SimpleObjectInfo.CheckVisibility` to select the targets visible to the current viewer.
- Apply the visible target IDs to the comment query before pagination and counting. In the reported A/B/C example, page 1 now contains C with `count: 1`, and page 2 is empty with `count: 1`.
- Reuse the resolved object information when building the response. Existing comment-page callers remain unrestricted when the object-ID filter is nil, while an empty filter returns no comments.
- Add real SQLite regression tests covering pagination, repeated targets, user and comment-status isolation, empty and missing targets, question and answer ownership, moderator access, hidden parent questions, closed questions, and tag targets.
## Validation
Passed locally:
- `go test ./internal/service/comment ./internal/repo/repo_test -count=1` (SQLite)
- `go build ./...`
- `go vet ./...`
- `golangci-lint run ./internal/service/comment/... ./internal/repo/comment/... ./internal/repo/repo_test/...`
- `git diff --check`
The new service regression tests were also run against the old implementation and reproduced the incorrect counts and pagination.
MySQL/PostgreSQL tests were not run because the local Docker socket is inaccessible.
## Trade-off
Each request checks all distinct comment targets for the profile user before querying the requested page. Request cost and the size of the SQL `IN` filter therefore grow with the number of distinct targets; large-scale performance has not been benchmarked.
Related: #1648 proposes another fix for the same issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@answer.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@answer.apache.org
For additional commands, e-mail: issues-help@answer.apache.org