mirror of
https://github.com/GrassrootsEconomics/cic-dw.git
synced 2026-05-20 04:41:09 +02:00
fix: pagination queries
- refactor keyset pagination query to correctly fecth previous page - remove pagination from token list - add fetch latest transactions by token
This commit is contained in:
@@ -6,29 +6,32 @@ import (
|
||||
)
|
||||
|
||||
type Pagination struct {
|
||||
PerPage int
|
||||
Cursor int
|
||||
Forward bool
|
||||
PerPage int
|
||||
Cursor int
|
||||
Next bool
|
||||
FirstPage bool
|
||||
}
|
||||
|
||||
func GetPagination(q url.Values) Pagination {
|
||||
var (
|
||||
pp, _ = strconv.Atoi(q.Get("per_page"))
|
||||
cursor, _ = strconv.Atoi(q.Get("cursor"))
|
||||
forward, _ = strconv.ParseBool(q.Get("forward"))
|
||||
pp, _ = strconv.Atoi(q.Get("per_page"))
|
||||
cursor, _ = strconv.Atoi(q.Get("cursor"))
|
||||
next, _ = strconv.ParseBool(q.Get("next"))
|
||||
firstPage = false
|
||||
)
|
||||
|
||||
if pp > 100 {
|
||||
pp = 100
|
||||
}
|
||||
|
||||
if !forward && cursor < 1 {
|
||||
cursor = 1
|
||||
if !next && cursor < 1 {
|
||||
firstPage = true
|
||||
}
|
||||
|
||||
return Pagination{
|
||||
PerPage: pp,
|
||||
Cursor: cursor,
|
||||
Forward: forward,
|
||||
PerPage: pp,
|
||||
Cursor: cursor,
|
||||
Next: next,
|
||||
FirstPage: firstPage,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user