Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: sort active namespace #61

Merged
merged 2 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions cmd/api/docs/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/api/docs/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/api/docs/swagger.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion cmd/api/handler/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmd/api/handler/namespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading