@@ -353,6 +353,44 @@ func GetUserFollowing(ctx context.Context, u, viewer *User, listOptions db.ListO
353
353
return users , count , err
354
354
}
355
355
356
+ // GetUserFollowers returns range of user's followers.
357
+ func GetUserFollowersCount (ctx context.Context , u , viewer * User , listOptions db.ListOptions ) (int64 , error ) {
358
+ sess := db .GetEngine (ctx ).
359
+ Select ("`user`.*" ).
360
+ Join ("LEFT" , "follow" , "`user`.id=follow.user_id" ).
361
+ Where ("follow.follow_id=?" , u .ID ).
362
+ And ("`user`.type=?" , UserTypeIndividual ).
363
+ And (isUserVisibleToViewerCond (viewer ))
364
+
365
+ if listOptions .Page != 0 {
366
+ sess = db .SetSessionPagination (sess , & listOptions )
367
+ count , err := sess .Count ()
368
+ return count , err
369
+ }
370
+
371
+ count , err := sess .Count ()
372
+ return count , err
373
+ }
374
+
375
+ // GetUserFollowing returns range of user's following.
376
+ func GetUserFollowingCount (ctx context.Context , u , viewer * User , listOptions db.ListOptions ) (int64 , error ) {
377
+ sess := db .GetEngine (db .DefaultContext ).
378
+ Select ("`user`.*" ).
379
+ Join ("LEFT" , "follow" , "`user`.id=follow.follow_id" ).
380
+ Where ("follow.user_id=?" , u .ID ).
381
+ And ("`user`.type IN (?, ?)" , UserTypeIndividual , UserTypeOrganization ).
382
+ And (isUserVisibleToViewerCond (viewer ))
383
+
384
+ if listOptions .Page != 0 {
385
+ sess = db .SetSessionPagination (sess , & listOptions )
386
+ count , err := sess .Count ()
387
+ return count , err
388
+ }
389
+
390
+ count , err := sess .Count ()
391
+ return count , err
392
+ }
393
+
356
394
// NewGitSig generates and returns the signature of given user.
357
395
func (u * User ) NewGitSig () * git.Signature {
358
396
return & git.Signature {
0 commit comments