gitea/services/context
Lunny Xiao d21ce9fa07
Improve the performance when detecting the file editable (#34653)
Noticed the SQL will be executed 4 times when visit the file render view
page. For a repository which have many pull requests, it maybe slow.
```SQL
2025/06/08 15:24:44 models/issues/pull_list.go:69:GetUnmergedPullRequestsByHeadInfo() [I] [SQL] SELECT * FROM `pull_request` INNER JOIN `issue` ON issue.id = pull_request.issue_id WHERE (head_repo_id = ? AND head_branch = ? AND has_merged = ? AND issue.is_closed = ? AND flow = ?) [393 main false false 0] - 2.004167ms
2025/06/08 15:24:44 models/issues/pull_list.go:69:GetUnmergedPullRequestsByHeadInfo() [I] [SQL] SELECT * FROM `pull_request` INNER JOIN `issue` ON issue.id = pull_request.issue_id WHERE (head_repo_id = ? AND head_branch = ? AND has_merged = ? AND issue.is_closed = ? AND flow = ?) [393 main false false 0] - 1.03975ms
2025/06/08 15:24:44 models/issues/pull_list.go:69:GetUnmergedPullRequestsByHeadInfo() [I] [SQL] SELECT * FROM `pull_request` INNER JOIN `issue` ON issue.id = pull_request.issue_id WHERE (head_repo_id = ? AND head_branch = ? AND has_merged = ? AND issue.is_closed = ? AND flow = ?) [393 main false false 0] - 881.583µs
2025/06/08 15:24:44 models/issues/pull_list.go:69:GetUnmergedPullRequestsByHeadInfo() [I] [SQL] SELECT * FROM `pull_request` INNER JOIN `issue` ON issue.id = pull_request.issue_id WHERE (head_repo_id = ? AND head_branch = ? AND has_merged = ? AND issue.is_closed = ? AND flow = ?) [393 main false false 0] - 935.084µs
```

This PR did a refactor to query it once only.
2025-06-12 18:12:45 +00:00
..
upload enable staticcheck QFxxxx rules (#34064) 2025-03-29 17:32:28 -04:00
access_log.go Enable addtional linters (#34085) 2025-04-01 10:14:01 +00:00
access_log_test.go Enable addtional linters (#34085) 2025-04-01 10:14:01 +00:00
api.go Add endpoint deleting workflow run (#34337) 2025-05-13 19:18:13 +00:00
api_org.go Move context from modules to services (#29440) 2024-02-27 08:12:22 +01:00
api_test.go Enable testifylint rules (#34075) 2025-03-31 01:53:48 -04:00
base.go Enable addtional linters (#34085) 2025-04-01 10:14:01 +00:00
base_form.go [Feature] Private README.md for organization (#32872) 2024-12-31 04:22:09 +00:00
base_path.go Clarify path param naming (#32969) 2024-12-24 13:47:45 +00:00
base_test.go Enable addtional linters (#34085) 2025-04-01 10:14:01 +00:00
captcha.go Refactor template & test related code (#32938) 2024-12-22 15:33:19 +00:00
context.go Add endpoint deleting workflow run (#34337) 2025-05-13 19:18:13 +00:00
context_cookie.go Move context from modules to services (#29440) 2024-02-27 08:12:22 +01:00
context_model.go Refactor context repository (#33202) 2025-01-12 03:39:46 +00:00
context_request.go Move context from modules to services (#29440) 2024-02-27 08:12:22 +01:00
context_response.go Do not show 500 error when default branch doesn't exist (#34096) 2025-04-01 21:39:00 -07:00
context_template.go Move context from modules to services (#29440) 2024-02-27 08:12:22 +01:00
context_test.go Refactor request context (#32956) 2024-12-24 11:43:57 +08:00
csrf.go Refactor CSRF token (#32216) 2024-10-10 03:48:21 +00:00
org.go Fix team permission (#34128) 2025-04-08 04:15:15 +00:00
package.go Add a config option to block "expensive" pages for anonymous users (#34024) 2025-03-30 05:26:19 +00:00
pagination.go Only use prev and next buttons for pagination on user dashboard (#33981) 2025-03-23 19:52:43 +00:00
permission.go Refactor error system (#33610) 2025-02-16 22:13:17 -08:00
private.go Enable addtional linters (#34085) 2025-04-01 10:14:01 +00:00
repo.go Improve the performance when detecting the file editable (#34653) 2025-06-12 18:12:45 +00:00
response.go Remove duplicate "ResponseWriter.Status" method (#33346) 2025-01-22 06:37:52 +00:00
user.go Refactor error system (#33626) 2025-02-17 12:41:03 -08:00
utils.go Move context from modules to services (#29440) 2024-02-27 08:12:22 +01:00
xsrf.go Move context from modules to services (#29440) 2024-02-27 08:12:22 +01:00
xsrf_test.go Move context from modules to services (#29440) 2024-02-27 08:12:22 +01:00