Skip to content

Commit

Permalink
Merge pull request opendatahub-io#66 from HumairAK/RHOAIENG-8225-bug-fix
Browse files Browse the repository at this point in the history
UPSTREAM: <carry>: use asc artifact ordering by default.
  • Loading branch information
openshift-merge-bot[bot] authored Jul 18, 2024
2 parents 7d7659c + 41c133e commit bbfb589
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 bbfb589

Please sign in to comment.