Skip to content

Commit a908b29

Browse files
cristalolegtechknowlogick
authored andcommitted
Remove duplicated if bodies (#5121)
1 parent 616b8f4 commit a908b29

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

models/user.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"errors"
1515
"fmt"
1616
"image"
17+
1718
// Needed for jpeg support
1819
_ "image/jpeg"
1920
"image/png"
@@ -377,12 +378,8 @@ func (u *User) GetFollowers(page int) ([]*User, error) {
377378
users := make([]*User, 0, ItemsPerPage)
378379
sess := x.
379380
Limit(ItemsPerPage, (page-1)*ItemsPerPage).
380-
Where("follow.follow_id=?", u.ID)
381-
if setting.UsePostgreSQL {
382-
sess = sess.Join("LEFT", "follow", "`user`.id=follow.user_id")
383-
} else {
384-
sess = sess.Join("LEFT", "follow", "`user`.id=follow.user_id")
385-
}
381+
Where("follow.follow_id=?", u.ID).
382+
Join("LEFT", "follow", "`user`.id=follow.user_id")
386383
return users, sess.Find(&users)
387384
}
388385

@@ -396,12 +393,8 @@ func (u *User) GetFollowing(page int) ([]*User, error) {
396393
users := make([]*User, 0, ItemsPerPage)
397394
sess := x.
398395
Limit(ItemsPerPage, (page-1)*ItemsPerPage).
399-
Where("follow.user_id=?", u.ID)
400-
if setting.UsePostgreSQL {
401-
sess = sess.Join("LEFT", "follow", "`user`.id=follow.follow_id")
402-
} else {
403-
sess = sess.Join("LEFT", "follow", "`user`.id=follow.follow_id")
404-
}
396+
Where("follow.user_id=?", u.ID).
397+
Join("LEFT", "follow", "`user`.id=follow.follow_id")
405398
return users, sess.Find(&users)
406399
}
407400

0 commit comments

Comments
 (0)