Skip to content

Commit

Permalink
RHINENG-3098: remove unused Paginate function
Browse files Browse the repository at this point in the history
  • Loading branch information
psegedy committed Dec 15, 2023
1 parent d46a93b commit ad10c46
Showing 1 changed file with 0 additions and 25 deletions.
25 changes: 0 additions & 25 deletions manager/controllers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -707,31 +707,6 @@ func isFilterInURLValid(c *gin.Context) bool {
return true
}

// Pagination query for handlers where ListCommon is not used
func Paginate(tx *gorm.DB, limit *int, offset *int) (int, int, error) {
var total int64
if limit == nil {
limit = &core.DefaultLimit
}
if offset == nil {
offset = &core.DefaultOffset
}
if err := utils.CheckLimitOffset(*limit, *offset); err != nil {
return *limit, *offset, err
}

tx.Count(&total)
if total < int64(*offset) {
return *limit, *offset, errors.New(InvalidOffsetMsg)
}
if *limit != -1 {
// consistency with ListCommon
tx.Limit(*limit)
}
tx.Offset(*offset)
return *limit, *offset, nil
}

// Return value for v3 api or return nil for previous versions
func APIV3Compat[T any](x *T, apiver int) *T {
if apiver < 3 {
Expand Down

0 comments on commit ad10c46

Please sign in to comment.