aboutsummaryrefslogtreecommitdiffstats
path: root/models/issue_assignees.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-09-23 16:45:36 +0100
committerGitHub <noreply@github.com>2021-09-23 23:45:36 +0800
commit9302eba971611601c3ebf6024e22a11c63f4e151 (patch)
treea3e5583986161ef62e7affc694098279ecf2217d /models/issue_assignees.go
parentb22be7f594401d7bd81196750456ce52185bd391 (diff)
downloadgitea-9302eba971611601c3ebf6024e22a11c63f4e151.tar.gz
gitea-9302eba971611601c3ebf6024e22a11c63f4e151.zip
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>
Diffstat (limited to 'models/issue_assignees.go')
-rw-r--r--models/issue_assignees.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/models/issue_assignees.go b/models/issue_assignees.go
index 6b2d8bb347..0f7ba2d702 100644
--- a/models/issue_assignees.go
+++ b/models/issue_assignees.go
@@ -26,7 +26,7 @@ func init() {
// LoadAssignees load assignees of this issue.
func (issue *Issue) LoadAssignees() error {
- return issue.loadAssignees(db.DefaultContext().Engine())
+ return issue.loadAssignees(db.GetEngine(db.DefaultContext))
}
// This loads all assignees of an issue
@@ -56,7 +56,7 @@ func (issue *Issue) loadAssignees(e db.Engine) (err error) {
// User permissions must be verified elsewhere if required.
func GetAssigneeIDsByIssue(issueID int64) ([]int64, error) {
userIDs := make([]int64, 0, 5)
- return userIDs, db.DefaultContext().Engine().Table("issue_assignees").
+ return userIDs, db.GetEngine(db.DefaultContext).Table("issue_assignees").
Cols("assignee_id").
Where("issue_id = ?", issueID).
Distinct("assignee_id").
@@ -65,7 +65,7 @@ func GetAssigneeIDsByIssue(issueID int64) ([]int64, error) {
// GetAssigneesByIssue returns everyone assigned to that issue
func GetAssigneesByIssue(issue *Issue) (assignees []*User, err error) {
- return getAssigneesByIssue(db.DefaultContext().Engine(), issue)
+ return getAssigneesByIssue(db.GetEngine(db.DefaultContext), issue)
}
func getAssigneesByIssue(e db.Engine, issue *Issue) (assignees []*User, err error) {
@@ -79,7 +79,7 @@ func getAssigneesByIssue(e db.Engine, issue *Issue) (assignees []*User, err erro
// IsUserAssignedToIssue returns true when the user is assigned to the issue
func IsUserAssignedToIssue(issue *Issue, user *User) (isAssigned bool, err error) {
- return isUserAssignedToIssue(db.DefaultContext().Engine(), issue, user)
+ return isUserAssignedToIssue(db.GetEngine(db.DefaultContext), issue, user)
}
func isUserAssignedToIssue(e db.Engine, issue *Issue, user *User) (isAssigned bool, err error) {
@@ -94,7 +94,7 @@ func clearAssigneeByUserID(sess db.Engine, userID int64) (err error) {
// ToggleAssignee changes a user between assigned and not assigned for this issue, and make issue comment for it.
func (issue *Issue) ToggleAssignee(doer *User, assigneeID int64) (removed bool, comment *Comment, err error) {
- sess := db.DefaultContext().NewSession()
+ sess := db.NewSession(db.DefaultContext)
defer sess.Close()
if err := sess.Begin(); err != nil {