HotFix: Hide private partisipation in Orgs (#13994) (#14031)

* HotFix: Hide private partisipation in Orgs

Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
6543 2020-12-17 21:32:24 +00:00 committed by GitHub
parent b8a2cd9f40
commit df11075389
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 11 deletions

View file

@ -66,3 +66,22 @@ func GetListOptions(ctx *context.APIContext) models.ListOptions {
PageSize: convert.ToCorrectPageSize(ctx.QueryInt("limit")),
}
}
// PaginateUserSlice cut a slice of Users as per pagination options
// TODO: make it generic
func PaginateUserSlice(items []*models.User, page, pageSize int) []*models.User {
if page != 0 {
page--
}
if page*pageSize >= len(items) {
return items[len(items):]
}
items = items[page*pageSize:]
if len(items) > pageSize {
return items[:pageSize]
}
return items
}