jojo/routers/web/repo
Mathieu Fenniak e14e220651 perf: bulk load resolvers & reactions on pull request comments (#11988)
Optimize loading pull request review comments, which currently perform separate database queries for each comment in order to load the resolver of the comment, and the reactions on that comment, and the users on each reaction of the comments.

I stumbled across this ugly code, which enticed me to look into this:

80d840c128/routers/web/repo/pull.go (L1107-L1120)

It appeared to load the attachments from each comment on the pull request review page in separate database queries.  It turned out to be a noop, as the attachments are already loaded in bulk:

80d840c128/models/issues/comment_code.go (L120-L122)

but the `findCodeComments` method loads the "resolver doer" and the reactions one-by-one for each comment.  So I fixed that instead, and removed the ineffective deeply nested for loop.

## Checklist

The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. All work and communication must conform to Forgejo's [AI Agreement](https://codeberg.org/forgejo/governance/src/branch/main/AIAgreement.md). There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org).

### Tests for Go changes

- I added test coverage for Go changes...
  - [x] in their respective `*_test.go` for unit tests.
  - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server.
- I ran...
  - [x] `make pr-go` before pushing

### Documentation

- [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change.
- [x] I did not document these changes and I do not expect someone else to do it.

### Release notes

- [ ] This change will be noticed by a Forgejo user or admin (feature, bug fix, performance, etc.). I suggest to include a release note for this change.
- [x] This change is not visible to a Forgejo user or admin (refactor, dependency upgrade, etc.). I think there is no need to add a release note for this change.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/11988
Reviewed-by: Andreas Ahlenstorf <aahlenst@noreply.codeberg.org>
Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net>
Co-committed-by: Mathieu Fenniak <mathieu@fenniak.net>
2026-04-05 14:37:09 +02:00
..
actions feat: allow runners to request a particular job (#11676) 2026-03-25 17:27:05 +01:00
badges chore: ensure consistent import aliasing for services and models (#10253) 2025-11-30 17:00:57 +01:00
flags chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
setting fix: store pull mirror creds encrypted with keying (#11909) 2026-04-04 13:53:22 +02:00
action_aggregator_test.go chore: ensure consistent import aliasing for services and models (#10253) 2025-11-30 17:00:57 +01:00
activity.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
attachment.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
blame.go blame: count lines without reading blob 2025-06-24 17:36:13 +02:00
branch.go chore: add modernizer linter (#11936) 2026-04-02 03:29:37 +02:00
card.go feat: strip newlines on og image rendering (#10914) 2026-01-19 18:41:20 +01:00
cherry_pick.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
code_frequency.go chore: ensure consistent import aliasing for services and models (#10253) 2025-11-30 17:00:57 +01:00
commit.go chore: add modernizer linter (#11936) 2026-04-02 03:29:37 +02:00
commit_test.go fix(ui): improve Git notes editing (#11365) 2026-03-10 23:49:18 +01:00
compare.go feat: allow PRs between common forks of the same base repository (#9045) 2025-10-01 04:58:12 +02:00
contributors.go chore: ensure consistent import aliasing for services and models (#10253) 2025-11-30 17:00:57 +01:00
download.go git/commit: re-implement submodules file reader (#8438) 2025-07-15 00:20:00 +02:00
editor.go chore: add modernizer linter (#11936) 2026-04-02 03:29:37 +02:00
editor_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
find.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
githttp.go chore: add modernizer linter (#11936) 2026-04-02 03:29:37 +02:00
githttp_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
helper.go feat(build): improve lint-locale-usage further (#8736) 2025-08-27 23:47:34 +02:00
helper_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue.go perf: bulk load resolvers & reactions on pull request comments (#11988) 2026-04-05 14:37:09 +02:00
issue_content_history.go 2025-11-21 combined security patches (#10037) 2025-11-21 05:23:43 +01:00
issue_dependency.go chore: fix typos throughout the codebase (#10753) 2026-01-26 22:57:33 +01:00
issue_label.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_label_test.go chore: add modernizer linter (#11936) 2026-04-02 03:29:37 +02:00
issue_lock.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_pin.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_stopwatch.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_test.go fix: honor org/user project in new issue (#9906) 2026-02-16 05:52:47 +01:00
issue_timetrack.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue_watch.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
main_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
middlewares.go chore: fix typos throughout the codebase (#10753) 2026-01-26 22:57:33 +01:00
migrate.go chore: remove redundant code (#9378) 2025-09-22 09:18:19 +02:00
milestone.go chore: add modernizer linter (#11936) 2026-04-02 03:29:37 +02:00
packages.go chore: add modernizer linter (#11936) 2026-04-02 03:29:37 +02:00
patch.go chore: fix typos throughout the codebase (#10753) 2026-01-26 22:57:33 +01:00
projects.go chore: add modernizer linter (#11936) 2026-04-02 03:29:37 +02:00
projects_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
pull.go perf: bulk load resolvers & reactions on pull request comments (#11988) 2026-04-05 14:37:09 +02:00
pull_review.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
pull_review_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
pull_test.go fix(ui): improve Git notes editing (#11365) 2026-03-10 23:49:18 +01:00
recent_commits.go Hide activity contributors, recent commits and code frequrency left tabs if there is no code permission (#34053) 2025-04-01 02:28:02 +02:00
release.go fix(10359): Count releases correctly when using filters (q) (#10387) 2025-12-11 05:13:21 +01:00
release_test.go fix(10359): Count releases correctly when using filters (q) (#10387) 2025-12-11 05:13:21 +01:00
render.go feat: detect Interlisp sources as text (#8377) 2025-07-02 07:38:46 +02:00
repo.go chore: add modernizer linter (#11936) 2026-04-02 03:29:37 +02:00
search.go fix(ui): add missing translation for code search when keyword is empty string (#10964) 2026-01-21 16:42:18 +01:00
topic.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
treelist.go git/commit: re-implement submodules file reader (#8438) 2025-07-15 00:20:00 +02:00
view.go refactor: replace Value() from Option[T] with Get() & ValueOrZeroValue() (#11218) 2026-02-10 16:41:21 +01:00
view_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
wiki.go chore: add modernizer linter (#11936) 2026-04-02 03:29:37 +02:00
wiki_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00