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

Method ListFollowings

internal/database/users.go:840–858  ·  view source on GitHub ↗

ListFollowings returns a list of users that are followed by 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

838// Results are paginated by given page and page size, and sorted by the time of
839// follow in descending order.
840func (s *UsersStore) ListFollowings(ctx context.Context, userID int64, page, pageSize int) ([]*User, error) {
841 /*
842 Equivalent SQL for PostgreSQL:
843
844 SELECT * FROM "user"
845 LEFT JOIN follow ON follow.user_id = "user".id
846 WHERE follow.user_id = @userID
847 ORDER BY follow.id DESC
848 LIMIT @limit OFFSET @offset
849 */
850 users := make([]*User, 0, pageSize)
851 return users, s.db.WithContext(ctx).
852 Joins(dbutil.Quote("LEFT JOIN follow ON follow.follow_id = %s.id", "user")).
853 Where("follow.user_id = ?", userID).
854 Limit(pageSize).Offset((page - 1) * pageSize).
855 Order("follow.id DESC").
856 Find(&users).
857 Error
858}
859
860func searchUserByName(ctx context.Context, db *gorm.DB, userType UserType, keyword string, page, pageSize int, orderBy string) ([]*User, int64, error) {
861 if keyword == "" {

Callers 3

usersListFollowingsFunction · 0.80
FollowingFunction · 0.80
listUserFollowingFunction · 0.80

Calls 3

QuoteFunction · 0.92
WhereMethod · 0.80
FindMethod · 0.65

Tested by 1

usersListFollowingsFunction · 0.64