Remove duplicated if bodies (#5121)

This commit is contained in:
Oleg Kovalov 2018-10-19 18:49:36 +02:00 committed by techknowlogick
parent 616b8f42f9
commit a908b29a74

View file

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