diff --git a/modules/backend/src/main/scala/service.player.scala b/modules/backend/src/main/scala/service.player.scala index 6c42010..f8e15e3 100644 --- a/modules/backend/src/main/scala/service.player.scala +++ b/modules/backend/src/main/scala/service.player.scala @@ -28,14 +28,14 @@ class PlayerServiceImpl(db: Db)(using Logger[IO]) extends PlayerService[IO]: blitzMax: Option[Rating], name: Option[String], page: Option[PageNumber], - size: Option[Int] + pageSize: Option[Int] ): IO[GetPlayersOutput] = - val _size = size.getOrElse(Models.Pagination.defaultLimit) - val _page = page.flatMap(_.value.toIntOption).getOrElse(Models.Pagination.firstPage) - val paging = Models.Pagination.fromPageAndSize(_page, _size) - val _order = order.map(_.to[Models.Order]).getOrElse(Models.Order.Desc) - val _sortBy = sortBy.map(_.to[Models.SortBy]).getOrElse(Models.SortBy.Name) - val sorting = Models.Sorting(_sortBy, _order) + val _pageSize = pageSize.getOrElse(Models.Pagination.defaultLimit) + val _page = page.flatMap(_.value.toIntOption).getOrElse(Models.Pagination.firstPage) + val paging = Models.Pagination.fromPageAndSize(_page, _pageSize) + val _order = order.map(_.to[Models.Order]).getOrElse(Models.Order.Desc) + val _sortBy = sortBy.map(_.to[Models.SortBy]).getOrElse(Models.SortBy.Name) + val sorting = Models.Sorting(_sortBy, _order) val filter = Models.Filter( isActive, Models.RatingRange(standardMin.map(_.value), standardMax.map(_.value)), @@ -48,7 +48,8 @@ class PlayerServiceImpl(db: Db)(using Logger[IO]) extends PlayerService[IO]: error"Error in getPlayers with $filter, $e" *> IO.raiseError(InternalServerError("Internal server error")) .map(_.map(_.transform)) - .map(xs => GetPlayersOutput(xs, Option.when(xs.size == _size)(PageNumber(paging.nextPage.toString())))) + .map: xs => + GetPlayersOutput(xs, Option.when(xs.size == _pageSize)(PageNumber(paging.nextPage.toString()))) override def getPlayerById(id: PlayerId): IO[Player] = db.playerById(id.value) diff --git a/modules/smithy/src/main/smithy/players.smithy b/modules/smithy/src/main/smithy/players.smithy index cdacd83..0f24d29 100644 --- a/modules/smithy/src/main/smithy/players.smithy +++ b/modules/smithy/src/main/smithy/players.smithy @@ -11,7 +11,7 @@ service PlayerService { } @readonly -@paginated(inputToken: "page", outputToken: "nextPage", pageSize: "size") +@paginated(inputToken: "page", outputToken: "nextPage", pageSize: "pageSize") @http(method: "GET", uri: "/api/players", code: 200) operation GetPlayers { input: GetPlayersInput, @@ -60,9 +60,9 @@ structure GetPlayersByIdsOutput { structure GetPlayersInput with [SortingMixin, FilterMixin] { @httpQuery("page") page: PageNumber - @httpQuery("size") + @httpQuery("page_size") @range(min: 1, max: 100) - size: Integer + pageSize: Integer } structure GetPlayersOutput {