diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2017-01-28 00:11:41 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-28 00:11:41 +0800 |
commit | bb5a6b7a07125b29604f479f45e59073cb3d4648 (patch) | |
tree | 590eeb774f6cb16bc8f8b12dc8f92fb6fd11b443 /models/org.go | |
parent | 25663b58161c48bdc8e9cae900544378dede0d2b (diff) | |
download | gitea-bb5a6b7a07125b29604f479f45e59073cb3d4648.tar.gz gitea-bb5a6b7a07125b29604f479f45e59073cb3d4648.zip |
fix xorm NewSession uncorrected usages (#774)
Diffstat (limited to 'models/org.go')
-rw-r--r-- | models/org.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/models/org.go b/models/org.go index d44547a0f9..02f7bc4e7d 100644 --- a/models/org.go +++ b/models/org.go @@ -345,13 +345,15 @@ func getOrgsByUserID(sess *xorm.Session, userID int64, showAll bool) ([]*User, e // GetOrgsByUserID returns a list of organizations that the given user ID // has joined. func GetOrgsByUserID(userID int64, showAll bool) ([]*User, error) { - return getOrgsByUserID(x.NewSession(), userID, showAll) + sess := x.NewSession() + defer sess.Close() + return getOrgsByUserID(sess, userID, showAll) } // GetOrgsByUserIDDesc returns a list of organizations that the given user ID // has joined, ordered descending by the given condition. func GetOrgsByUserIDDesc(userID int64, desc string, showAll bool) ([]*User, error) { - return getOrgsByUserID(x.NewSession().Desc(desc), userID, showAll) + return getOrgsByUserID(x.Desc(desc), userID, showAll) } func getOwnedOrgsByUserID(sess *xorm.Session, userID int64) ([]*User, error) { @@ -367,14 +369,14 @@ func getOwnedOrgsByUserID(sess *xorm.Session, userID int64) ([]*User, error) { // GetOwnedOrgsByUserID returns a list of organizations are owned by given user ID. func GetOwnedOrgsByUserID(userID int64) ([]*User, error) { sess := x.NewSession() + defer sess.Close() return getOwnedOrgsByUserID(sess, userID) } // GetOwnedOrgsByUserIDDesc returns a list of organizations are owned by // given user ID, ordered descending by the given condition. func GetOwnedOrgsByUserIDDesc(userID int64, desc string) ([]*User, error) { - sess := x.NewSession() - return getOwnedOrgsByUserID(sess.Desc(desc), userID) + return getOwnedOrgsByUserID(x.Desc(desc), userID) } // GetOrgUsersByUserID returns all organization-user relations by user ID. |