1
0
Fork 0
forked from forgejo/forgejo

Add AbsoluteListOptions (#17028)

This PR adds a `ListOptions` type which is not paged but uses absolute values. It is implemented as discussed in Discord.
Extracted from #16510 to clean that PR.
This commit is contained in:
KN4CK3R 2021-09-14 19:48:27 +02:00 committed by GitHub
parent 0a542dd59f
commit 87505a9464
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 161 additions and 58 deletions

View file

@ -195,7 +195,7 @@ func SearchPublicKey(uid int64, fingerprint string) ([]*PublicKey, error) {
func ListPublicKeys(uid int64, listOptions ListOptions) ([]*PublicKey, error) {
sess := x.Where("owner_id = ? AND type != ?", uid, KeyTypePrincipal)
if listOptions.Page != 0 {
sess = listOptions.setSessionPagination(sess)
sess = setSessionPagination(sess, &listOptions)
keys := make([]*PublicKey, 0, listOptions.PageSize)
return keys, sess.Find(&keys)