]> source.dussan.org Git - gitea.git/commitdiff
Remove duplicated if bodies (#5121)
authorOleg Kovalov <iamolegkovalov@gmail.com>
Fri, 19 Oct 2018 16:49:36 +0000 (18:49 +0200)
committertechknowlogick <hello@techknowlogick.com>
Fri, 19 Oct 2018 16:49:36 +0000 (12:49 -0400)
models/user.go

index 6a9828d5739c38121aa0b7f67b69d5ef8b2d471f..45bd4445ee0ddaffa6ed699afe430005d455ebaf 100644 (file)
@@ -14,6 +14,7 @@ import (
        "errors"
        "fmt"
        "image"
+
        // Needed for jpeg support
        _ "image/jpeg"
        "image/png"
@@ -377,12 +378,8 @@ func (u *User) GetFollowers(page int) ([]*User, error) {
        users := make([]*User, 0, ItemsPerPage)
        sess := x.
                Limit(ItemsPerPage, (page-1)*ItemsPerPage).
-               Where("follow.follow_id=?", u.ID)
-       if setting.UsePostgreSQL {
-               sess = sess.Join("LEFT", "follow", "`user`.id=follow.user_id")
-       } else {
-               sess = sess.Join("LEFT", "follow", "`user`.id=follow.user_id")
-       }
+               Where("follow.follow_id=?", u.ID).
+               Join("LEFT", "follow", "`user`.id=follow.user_id")
        return users, sess.Find(&users)
 }
 
@@ -396,12 +393,8 @@ func (u *User) GetFollowing(page int) ([]*User, error) {
        users := make([]*User, 0, ItemsPerPage)
        sess := x.
                Limit(ItemsPerPage, (page-1)*ItemsPerPage).
-               Where("follow.user_id=?", u.ID)
-       if setting.UsePostgreSQL {
-               sess = sess.Join("LEFT", "follow", "`user`.id=follow.follow_id")
-       } else {
-               sess = sess.Join("LEFT", "follow", "`user`.id=follow.follow_id")
-       }
+               Where("follow.user_id=?", u.ID).
+               Join("LEFT", "follow", "`user`.id=follow.follow_id")
        return users, sess.Find(&users)
 }