mirror of
https://codeberg.org/forgejo-aneksajo/forgejo-aneksajo.git
synced 2025-07-11 23:00:05 +02:00
DBContext is just a Context (#17100)
* DBContext is just a Context This PR removes some of the specialness from the DBContext and makes it context This allows us to simplify the GetEngine code to wrap around any context in future and means that we can change our loadRepo(e Engine) functions to simply take contexts. Signed-off-by: Andrew Thornton <art27@cantab.net> * fix unit tests Signed-off-by: Andrew Thornton <art27@cantab.net> * another place that needs to set the initial context Signed-off-by: Andrew Thornton <art27@cantab.net> * avoid race Signed-off-by: Andrew Thornton <art27@cantab.net> * change attachment error Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
parent
b22be7f594
commit
9302eba971
129 changed files with 1112 additions and 1022 deletions
|
@ -63,7 +63,7 @@ func (issues IssueList) loadRepositories(e db.Engine) ([]*Repository, error) {
|
|||
|
||||
// LoadRepositories loads issues' all repositories
|
||||
func (issues IssueList) LoadRepositories() ([]*Repository, error) {
|
||||
return issues.loadRepositories(db.DefaultContext().Engine())
|
||||
return issues.loadRepositories(db.GetEngine(db.DefaultContext))
|
||||
}
|
||||
|
||||
func (issues IssueList) getPosterIDs() []int64 {
|
||||
|
@ -502,33 +502,33 @@ func (issues IssueList) loadAttributes(e db.Engine) error {
|
|||
// LoadAttributes loads attributes of the issues, except for attachments and
|
||||
// comments
|
||||
func (issues IssueList) LoadAttributes() error {
|
||||
return issues.loadAttributes(db.DefaultContext().Engine())
|
||||
return issues.loadAttributes(db.GetEngine(db.DefaultContext))
|
||||
}
|
||||
|
||||
// LoadAttachments loads attachments
|
||||
func (issues IssueList) LoadAttachments() error {
|
||||
return issues.loadAttachments(db.DefaultContext().Engine())
|
||||
return issues.loadAttachments(db.GetEngine(db.DefaultContext))
|
||||
}
|
||||
|
||||
// LoadComments loads comments
|
||||
func (issues IssueList) LoadComments() error {
|
||||
return issues.loadComments(db.DefaultContext().Engine(), builder.NewCond())
|
||||
return issues.loadComments(db.GetEngine(db.DefaultContext), builder.NewCond())
|
||||
}
|
||||
|
||||
// LoadDiscussComments loads discuss comments
|
||||
func (issues IssueList) LoadDiscussComments() error {
|
||||
return issues.loadComments(db.DefaultContext().Engine(), builder.Eq{"comment.type": CommentTypeComment})
|
||||
return issues.loadComments(db.GetEngine(db.DefaultContext), builder.Eq{"comment.type": CommentTypeComment})
|
||||
}
|
||||
|
||||
// LoadPullRequests loads pull requests
|
||||
func (issues IssueList) LoadPullRequests() error {
|
||||
return issues.loadPullRequests(db.DefaultContext().Engine())
|
||||
return issues.loadPullRequests(db.GetEngine(db.DefaultContext))
|
||||
}
|
||||
|
||||
// GetApprovalCounts returns a map of issue ID to slice of approval counts
|
||||
// FIXME: only returns official counts due to double counting of non-official approvals
|
||||
func (issues IssueList) GetApprovalCounts() (map[int64][]*ReviewCount, error) {
|
||||
return issues.getApprovalCounts(db.DefaultContext().Engine())
|
||||
return issues.getApprovalCounts(db.GetEngine(db.DefaultContext))
|
||||
}
|
||||
|
||||
func (issues IssueList) getApprovalCounts(e db.Engine) (map[int64][]*ReviewCount, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue