@@ -19,30 +19,24 @@ func (s *Service) FindByIds(followerID, followeeID uint64) (*models.Followship,
19
19
return & followship , errors .Wrapf (r .Error , "followerId: %v, followeeId: %v" , followerID , followeeID )
20
20
}
21
21
22
- func (s * Service ) IndexFollowers (userId uint64 , lastId uint64 , count int ) ([]* models.Followship , error ) {
22
+ func (s * Service ) IndexFollowers (userId uint64 , lastUserId uint64 , count int ) ([]* models.Followship , error ) {
23
23
var followships []* models.Followship
24
- if count > 100 {
25
- count = 100
26
- }
27
24
r := s .database .Handler ().
28
25
Preload ("Follower" ).
29
26
Where ("followee_id = ?" , userId ).
30
- Where ("id < ? ORDER BY id DESC LIMIT ?" , lastId , count ).
27
+ Where ("follower_id < ? ORDER BY follower_id DESC LIMIT ?" , lastUserId , count ).
31
28
Find (& followships )
32
- return followships , errors .Wrapf (r .Error , "userId: %v, lastId : %v, count: %v" , userId , lastId , count )
29
+ return followships , errors .Wrapf (r .Error , "userId: %v, lastUserId : %v, count: %v" , userId , lastUserId , count )
33
30
}
34
31
35
- func (s * Service ) IndexFollowings (userId uint64 , lastId uint64 , count int ) ([]* models.Followship , error ) {
32
+ func (s * Service ) IndexFollowings (userId uint64 , lastUserId uint64 , count int ) ([]* models.Followship , error ) {
36
33
var followships []* models.Followship
37
- if count > 100 {
38
- count = 100
39
- }
40
34
r := s .database .Handler ().
41
35
Preload ("Followee" ).
42
36
Where ("follower_id = ?" , userId ).
43
- Where ("id < ? ORDER BY id DESC LIMIT ?" , lastId , count ).
37
+ Where ("followee_id < ? ORDER BY followee_id DESC LIMIT ?" , lastUserId , count ).
44
38
Find (& followships )
45
- return followships , errors .Wrapf (r .Error , "userId: %v, lastId : %v, count: %v" , userId , lastId , count )
39
+ return followships , errors .Wrapf (r .Error , "userId: %v, lastUserId : %v, count: %v" , userId , lastUserId , count )
46
40
}
47
41
48
42
func (s * Service ) CountFollowers (userId uint64 ) (int64 , error ) {
0 commit comments