Johannes Batzill 5337c46a4f Add Query and Sorting Capability to ListBranches API (#42)
This change adds the following to the list branches api:
- 'query' parameter for querying branches using arbitrary substrings
- 'sort' parameter for sorting the branches (name and date supported)
- 'direction' parameter for specifing the direction of the sorted output
2022-10-21 20:45:26 -07:00

28 lines
622 B
Go

// Copyright 2022 Harness Inc. All rights reserved.
// Use of this source code is governed by the Polyform Free Trial License
// that can be found in the LICENSE.md file for this repository.
package render
// pagelen calculates to total number of pages given the
// page size and total count of all paginated items.
func pagelen(size, total int) int {
quotient, remainder := total/size, total%size
switch {
case quotient == 0:
return 1
case remainder == 0:
return quotient
default:
return quotient + 1
}
}
// max returns the largest of x or y.
func max(x, y int) int {
if x > y {
return x
}
return y
}