From 76bb7b0226147fe9df526e8e6a227993bf535ba5 Mon Sep 17 00:00:00 2001 From: Deividas Petraitis Date: Fri, 15 Nov 2024 15:59:48 +0200 Subject: [PATCH] BE-636 | Bug fix --- pkg/api/v1beta1/pools/http.go | 26 ++++++++++---------------- pools/usecase/pools_usecase.go | 1 - 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/pkg/api/v1beta1/pools/http.go b/pkg/api/v1beta1/pools/http.go index 374ba80fc..c51e78755 100644 --- a/pkg/api/v1beta1/pools/http.go +++ b/pkg/api/v1beta1/pools/http.go @@ -29,27 +29,21 @@ func (r *GetPoolsRequest) UnmarshalHTTPRequest(c echo.Context) error { return err } - var pagination v1beta1.PaginationRequest - if !(&pagination).IsPresent(c) { - return nil // pagination is optional and is not present - } + if pagination := new(v1beta1.PaginationRequest); pagination.IsPresent(c) { + if err := pagination.UnmarshalHTTPRequest(c); err != nil { + return err + } - if err := (&pagination).UnmarshalHTTPRequest(c); err != nil { - return err + r.Pagination = pagination } - r.Pagination = &pagination - - var sort v1beta1.SortRequest - if !(&sort).IsPresent(c) { - return nil // sort is optional and is not present - } + if sort := new(v1beta1.SortRequest); sort.IsPresent(c) { + if err := sort.UnmarshalHTTPRequest(c); err != nil { + return err + } - if err := (&sort).UnmarshalHTTPRequest(c); err != nil { - return err + r.Sort = sort } - r.Sort = &sort - return nil } diff --git a/pools/usecase/pools_usecase.go b/pools/usecase/pools_usecase.go index e01bfd6c8..8e25844b1 100644 --- a/pools/usecase/pools_usecase.go +++ b/pools/usecase/pools_usecase.go @@ -358,7 +358,6 @@ func (p *poolsUseCase) GetPools(opts ...domain.PoolsOption) ([]sqsdomain.PoolI, var sortopts []func(sqsdomain.PoolI, sqsdomain.PoolI) bool if s := options.Sort; s != nil { for _, v := range s.Fields { - fmt.Println(v) switch v.Field { case "id": sortopts = append(sortopts, func(a, b sqsdomain.PoolI) bool {