MCPcopy Create free account
hub / github.com/gogs/gogs / ListFollowers

Method ListFollowers

internal/database/users.go:817–835  ·  view source on GitHub ↗

ListFollowers returns a list of users that are following the given user. Results are paginated by given page and page size, and sorted by the time of follow in descending order.

(ctx context.Context, userID int64, page, pageSize int)

Source from the content-addressed store, hash-verified

815// Results are paginated by given page and page size, and sorted by the time of
816// follow in descending order.
817func (s *UsersStore) ListFollowers(ctx context.Context, userID int64, page, pageSize int) ([]*User, error) {
818 /*
819 Equivalent SQL for PostgreSQL:
820
821 SELECT * FROM "user"
822 LEFT JOIN follow ON follow.user_id = "user".id
823 WHERE follow.follow_id = @userID
824 ORDER BY follow.id DESC
825 LIMIT @limit OFFSET @offset
826 */
827 users := make([]*User, 0, pageSize)
828 return users, s.db.WithContext(ctx).
829 Joins(dbutil.Quote("LEFT JOIN follow ON follow.user_id = %s.id", "user")).
830 Where("follow.follow_id = ?", userID).
831 Limit(pageSize).Offset((page - 1) * pageSize).
832 Order("follow.id DESC").
833 Find(&users).
834 Error
835}
836
837// ListFollowings returns a list of users that are followed by the given user.
838// Results are paginated by given page and page size, and sorted by the time of

Callers 4

usersListFollowersFunction · 0.80
usersListFollowingsFunction · 0.80
FollowersFunction · 0.80
listUserFollowersFunction · 0.80

Calls 3

QuoteFunction · 0.92
WhereMethod · 0.80
FindMethod · 0.65

Tested by 2

usersListFollowersFunction · 0.64
usersListFollowingsFunction · 0.64