fix: Sort workspace by name by created_at (#2214)

* fix: Sort workspace by name by created_at

Fix bug where deleting workspaces with the same name returns the
oldest deleted workspace
This commit is contained in:
Steven Masley
2022-06-10 09:58:42 -05:00
committed by GitHub
parent 953e8c8fe6
commit 6bee180bb3
10 changed files with 60 additions and 29 deletions

View File

@ -35,10 +35,8 @@ func (api *API) workspace(rw http.ResponseWriter, r *http.Request) {
return
}
// The `deleted` query parameter (which defaults to `false`) MUST match the
// `Deleted` field on the workspace otherwise you will get a 410 Gone.
var (
deletedStr = r.URL.Query().Get("deleted")
deletedStr = r.URL.Query().Get("include_deleted")
showDeleted = false
)
if deletedStr != "" {
@ -46,7 +44,7 @@ func (api *API) workspace(rw http.ResponseWriter, r *http.Request) {
showDeleted, err = strconv.ParseBool(deletedStr)
if err != nil {
httpapi.Write(rw, http.StatusBadRequest, httpapi.Response{
Message: fmt.Sprintf("Invalid boolean value %q for \"deleted\" query param.", deletedStr),
Message: fmt.Sprintf("Invalid boolean value %q for \"include_deleted\" query param.", deletedStr),
Validations: []httpapi.Error{
{Field: "deleted", Detail: "Must be a valid boolean"},
},