Skip to content

Commit

Permalink
Fixed json response of GetDeckCardsDue
Browse files Browse the repository at this point in the history
  • Loading branch information
4KevR committed Nov 27, 2023
1 parent 56fd142 commit e291a47
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion backend/api-documentation/decks/get due cards.bru
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ auth:bearer {
}

assert {
res.body: isNumber
res.body.dueCards: isNumber
}
4 changes: 2 additions & 2 deletions backend/pkg/converter/fiberSerializerTypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ type FiberGetGroupDecksResponseBody struct {
Decks []FiberDeck `json:"decks"`
}

type FiberGetUserDueCardsResponseBody struct {
type FiberGetDueResponseBody struct {
DueCards int64 `json:"dueCards"`
DueDecks int64 `json:"dueDecks"`
DueDecks int64 `json:"dueDecks,omitempty"`
}

type FiberGetUserGroupsResponseBody struct {
Expand Down
9 changes: 4 additions & 5 deletions backend/services/frontend/handler/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,10 +824,9 @@ func (e *Frontend) SrsDeckDueHandler(c *fiber.Ctx) error {
if err != nil {
return err
}
if rspSrsDue.DueCards == 0 {
return c.JSON(0)
}
return c.JSON(rspSrsDue)
return c.JSON(converter.FiberGetDueResponseBody{
DueCards: rspSrsDue.DueCards,
})
}

func (e *Frontend) SrsUserDueHandler(c *fiber.Ctx) error {
Expand All @@ -838,7 +837,7 @@ func (e *Frontend) SrsUserDueHandler(c *fiber.Ctx) error {
if err != nil {
return err
}
return c.JSON(converter.FiberGetUserDueCardsResponseBody{
return c.JSON(converter.FiberGetDueResponseBody{
DueCards: dueCards.DueCards,
DueDecks: dueCards.DueDecks,
})
Expand Down

0 comments on commit e291a47

Please sign in to comment.