From 3229cc1920b05069a47d6c790fdd3abc9650b1d5 Mon Sep 17 00:00:00 2001 From: sh-cha Date: Wed, 11 Dec 2024 13:44:28 +0900 Subject: [PATCH] change next to offset --- challenger/README.md | 4 ++-- challenger/challenger.go | 4 ++-- challenger/query.go | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/challenger/README.md b/challenger/README.md index 610b1ab..a79269d 100644 --- a/challenger/README.md +++ b/challenger/README.md @@ -189,7 +189,7 @@ curl localhost:3001/challenges default options - `limit`: 10 -- `next`: "" +- `offset`: "" - `order`: desc ```go @@ -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 [ diff --git a/challenger/challenger.go b/challenger/challenger.go index 097ca51..8a73e26 100644 --- a/challenger/challenger.go +++ b/challenger/challenger.go @@ -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 @@ -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 } diff --git a/challenger/query.go b/challenger/query.go index 49605cb..8f71984 100644 --- a/challenger/query.go +++ b/challenger/query.go @@ -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 := "" @@ -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 }