Skip to content

Commit

Permalink
change next to offset
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-cha committed Dec 11, 2024
1 parent 7680b3d commit 3229cc1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions challenger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ curl localhost:3001/challenges

default options
- `limit`: 10
- `next`: ""
- `offset`: ""
- `order`: desc

```go
Expand All @@ -199,7 +199,7 @@ type QueryChallengesResponse struct {
}
```

If `next` exists, you can continue querying by inserting it as the `next`.
If `next` exists, you can continue querying by inserting it as the `offset`.

```json
[
Expand Down
4 changes: 2 additions & 2 deletions challenger/challenger.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (c *Challenger) RegisterQuerier() {
return ctx.JSON(status)
})
c.server.RegisterQuerier("/challenges", func(ctx *fiber.Ctx) error {
next := ctx.Query("next", "")
offset := ctx.Query("offset", "")
limit := ctx.QueryInt("limit", 10)
if limit > 100 {
limit = 100
Expand All @@ -203,7 +203,7 @@ func (c *Challenger) RegisterQuerier() {
descOrder = false
}

res, err := c.QueryChallenges(next, ulimit, descOrder)
res, err := c.QueryChallenges(offset, ulimit, descOrder)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions challenger/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
challengertypes "github.com/initia-labs/opinit-bots/challenger/types"
)

func (c *Challenger) QueryChallenges(from string, limit uint64, descOrder bool) (res challengertypes.QueryChallengesResponse, err error) {
func (c *Challenger) QueryChallenges(offset string, limit uint64, descOrder bool) (res challengertypes.QueryChallengesResponse, err error) {
challenges := []challengertypes.Challenge{}
next := ""

Expand All @@ -29,8 +29,8 @@ func (c *Challenger) QueryChallenges(from string, limit uint64, descOrder bool)
}

var startKey []byte
if from != "" {
startKey, err = base64.StdEncoding.DecodeString(from)
if offset != "" {
startKey, err = base64.StdEncoding.DecodeString(offset)
if err != nil {
return challengertypes.QueryChallengesResponse{}, err
}
Expand Down

0 comments on commit 3229cc1

Please sign in to comment.