Skip to content

Commit

Permalink
UPSTREAM: <carry>: use asc artifact ordering by default.
Browse files Browse the repository at this point in the history
Signed-off-by: Humair Khan <[email protected]>
  • Loading branch information
HumairAK committed Jul 18, 2024
1 parent 7d7659c commit 41c133e
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion backend/api/v2beta1/artifacts.proto
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ message ListArtifactRequest {

// Optional. Ordering field. [default = ID]
Field order_by_field = 2;
// Optional. Can be either "asc" (ascending) or "dsc" (descending). [default = asc]
// Optional. Can be either "asc" (ascending) or "desc" (descending). [default = asc]
string order_by = 3;

// Optional. The next_page_token value returned from a previous List request, if any.
Expand Down
2 changes: 1 addition & 1 deletion backend/api/v2beta1/go_client/artifacts.pb.go

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

2 changes: 1 addition & 1 deletion backend/api/v2beta1/swagger/artifacts.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
},
{
"name": "order_by",
"description": "Optional. Can be either \"asc\" (ascending) or \"dsc\" (descending). [default = asc].",
"description": "Optional. Can be either \"asc\" (ascending) or \"desc\" (descending). [default = asc].",
"in": "query",
"required": false,
"type": "string"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
},
{
"name": "order_by",
"description": "Optional. Can be either \"asc\" (ascending) or \"dsc\" (descending). [default = asc].",
"description": "Optional. Can be either \"asc\" (ascending) or \"desc\" (descending). [default = asc].",
"in": "query",
"required": false,
"type": "string"
Expand Down
7 changes: 1 addition & 6 deletions backend/src/apiserver/server/artifact_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,8 @@ func (s *ArtifactServer) ListArtifacts(ctx context.Context, r *apiv2beta1.ListAr
orderByField := r.OrderByField.String()

orderByAsc := true
switch r.OrderBy {
case "asc":
orderByAsc = true
case "dsc":
if r.OrderBy == "desc" {
orderByAsc = false
default:
return nil, util.Wrap(err, "Invalid value for order_by, valid values are 'asc' or 'dsc'.")
}

maxResultSize := r.MaxResultSize
Expand Down
4 changes: 2 additions & 2 deletions backend/src/apiserver/server/artifact_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func TestListArtifacts(t *testing.T) {
artifactRequest: &apiv2beta1.ListArtifactRequest{
MaxResultSize: 2,
Namespace: "test-namespace",
OrderBy: "dsc",
OrderBy: "desc",
},
expectedArtifacts: []*apiv2beta1.Artifact{artifact1, artifact0},
wantErr: false,
Expand All @@ -200,7 +200,7 @@ func TestListArtifacts(t *testing.T) {
artifactRequest: &apiv2beta1.ListArtifactRequest{
MaxResultSize: 2,
Namespace: "",
OrderBy: "dsc",
OrderBy: "desc",
},
expectedArtifacts: []*apiv2beta1.Artifact{artifact1, artifact0},
wantErr: true,
Expand Down

0 comments on commit 41c133e

Please sign in to comment.