diff --git a/cmd/api/docs/docs.go b/cmd/api/docs/docs.go index 804097e3..73133867 100644 --- a/cmd/api/docs/docs.go +++ b/cmd/api/docs/docs.go @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: 2023 PK Lab AG -// SPDX-License-Identifier: MIT - // Package docs Code generated by swaggo/swag. DO NOT EDIT package docs @@ -1178,7 +1175,7 @@ const docTemplate = `{ "size" ], "type": "string", - "description": "Sort field", + "description": "Sort field. Default: time", "name": "sort", "in": "query" } diff --git a/cmd/api/docs/swagger.json b/cmd/api/docs/swagger.json index d91a22ea..bc229e15 100644 --- a/cmd/api/docs/swagger.json +++ b/cmd/api/docs/swagger.json @@ -1168,7 +1168,7 @@ "size" ], "type": "string", - "description": "Sort field", + "description": "Sort field. Default: time", "name": "sort", "in": "query" } diff --git a/cmd/api/docs/swagger.yaml b/cmd/api/docs/swagger.yaml index 1625fef9..1e207143 100644 --- a/cmd/api/docs/swagger.yaml +++ b/cmd/api/docs/swagger.yaml @@ -1865,7 +1865,7 @@ paths: description: Get last used namespace operationId: get-namespace-active parameters: - - description: Sort field + - description: 'Sort field. Default: time' enum: - time - pfb_count diff --git a/cmd/api/handler/namespace.go b/cmd/api/handler/namespace.go index b7c786b7..4e0324a3 100644 --- a/cmd/api/handler/namespace.go +++ b/cmd/api/handler/namespace.go @@ -325,7 +325,7 @@ type getActiveRequest struct { // @Description Get last used namespace // @Tags namespace // @ID get-namespace-active -// @Param sort query string false "Sort field" Enums(time,pfb_count,size) +// @Param sort query string false "Sort field. Default: time" Enums(time,pfb_count,size) // @Produce json // @Success 200 {array} responses.Namespace // @Failure 500 {object} Error @@ -336,6 +336,10 @@ func (handler *NamespaceHandler) GetActive(c echo.Context) error { return badRequestError(c, err) } + if req.Sort == "" { + req.Sort = "time" + } + active, err := handler.namespace.ListWithSort(c.Request().Context(), req.Sort, sdk.SortOrderDesc, 5, 0) if err != nil { return handleError(c, err, handler.namespace) diff --git a/cmd/api/handler/namespace_test.go b/cmd/api/handler/namespace_test.go index 5723d013..a8fbba48 100644 --- a/cmd/api/handler/namespace_test.go +++ b/cmd/api/handler/namespace_test.go @@ -412,7 +412,7 @@ func (s *NamespaceTestSuite) TestGetActive() { c.SetPath("/namespace/active") s.namespaces.EXPECT(). - ListWithSort(gomock.Any(), "", sdk.SortOrderDesc, 5, 0). + ListWithSort(gomock.Any(), "time", sdk.SortOrderDesc, 5, 0). Return([]storage.Namespace{ testNamespace, }, nil)