-
Notifications
You must be signed in to change notification settings - Fork 20
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
chore: change ListProjects API to request with multiple organizations #810
Conversation
@@ -118,7 +118,7 @@ message ListProjectsRequest { | |||
OrderDirection order_direction = 4; | |||
string search_keyword = 5; | |||
google.protobuf.BoolValue disabled = 6; | |||
string organization_id = 7; | |||
repeated string organization_ids = 7; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change. Is this API not used by any other services? If it is, we need to add a new field instead of modify it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have already checked with him.
He is aware of breaking change, but since there is no place on the console that uses this property, there is no need to add a new one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
He is aware of breaking change, but since there is no place on the console that uses this property, there is no need to add a new one.
Thank you for review.
Same understanding as above.
test/e2e/environment/project_test.go
Outdated
defer cancel() | ||
c := newEnvironmentClient(t) | ||
defer c.Close() | ||
pageSize := int64(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we want to test two or more organizations, we must set the pageSize
above 2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed to get two organization IDs.
ada5e82
test/e2e/environment/project_test.go
Outdated
if err != nil { | ||
t.Fatal(err) | ||
} | ||
length := int(math.Min(float64(len(orgResp.Organizations)), 2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
length := int(math.Min(float64(len(orgResp.Organizations)), 2)) | |
length := int(math.Min(float64(len(orgResp.Organizations)), pageSize)) |
@@ -118,7 +118,7 @@ message ListProjectsRequest { | |||
OrderDirection order_direction = 4; | |||
string search_keyword = 5; | |||
google.protobuf.BoolValue disabled = 6; | |||
string organization_id = 7; | |||
repeated string organization_ids = 7; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have already checked with him.
He is aware of breaking change, but since there is no place on the console that uses this property, there is no need to add a new one.
pkg/environment/api/project.go
Outdated
@@ -120,8 +120,12 @@ func (s *EnvironmentService) ListProjects( | |||
return nil, err | |||
} | |||
whereParts := []mysql.WherePart{} | |||
if req.OrganizationId != "" { | |||
whereParts = append(whereParts, mysql.NewFilter("organization_id", "=", req.OrganizationId)) | |||
if req.OrganizationIds != nil && len(req.OrganizationIds) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The len
also checks for nil.
if req.OrganizationIds != nil && len(req.OrganizationIds) > 0 { | |
if len(req.OrganizationIds) > 0 { |
pkg/environment/api/project.go
Outdated
if req.OrganizationId != "" { | ||
whereParts = append(whereParts, mysql.NewFilter("organization_id", "=", req.OrganizationId)) | ||
if req.OrganizationIds != nil && len(req.OrganizationIds) > 0 { | ||
oIDs := make([]interface{}, 0, len(req.OrganizationIds)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please refactor this by creating a new function, convToInterfaceSlice
.
E.g.
bucketeer/pkg/feature/api/feature.go
Lines 1770 to 1778 in 0685cc5
func convToInterfaceSlice( | |
slice []string, | |
) []interface{} { | |
result := make([]interface{}, 0, len(slice)) | |
for _, element := range slice { | |
result = append(result, element) | |
} | |
return result | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added convToInterfaceSlice()
and modified it to convert Organization IDs using that function.
b462fb9
test/e2e/environment/project_test.go
Outdated
} | ||
} | ||
if !found { | ||
t.Fatalf("received a project of a not request organization expected: %v, actual: %v", orgIds, project.OrganizationId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%s
for string.
t.Fatalf("received a project of a not request organization expected: %v, actual: %v", orgIds, project.OrganizationId) | |
t.Fatalf("received a project of a not request organization expected: %v, actual: %s", orgIds, project.OrganizationId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed a specifier for variable strings.
bcb4b3a
Thank you for your review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
When you merge, please use the following commit message.
chore: change ListProjects API to request with multiple organizations
Thank you for reviews! |
This pull request primarily focuses on modifying the way organization IDs are handled in the project listing functionality. The changes allow for handling multiple organization IDs instead of a single one. This is achieved by replacing the
organization_id
field withorganization_ids
in various files and functions. The changes also include updates to related tests to accommodate this new functionality.Here are the key changes:
Changes to Organization ID Handling:
pkg/account/api/api.go
: ThelistProjectsByOrganizationID
method in theAccountService
struct now accepts a slice of organization IDs instead of a single one.pkg/environment/api/project.go
: TheListProjects
method in theEnvironmentService
struct has been updated to handle a slice of organization IDs.proto/environment/service.proto
: TheListProjectsRequest
message now includes a repeated fieldorganization_ids
instead of a singleorganization_id
.Updates to Tests:
pkg/environment/api/project_test.go
: TheTestListProjectsMySQL
function now tests with multiple organization IDs.test/e2e/environment/project_test.go
: A new test functionTestListProjectsRequestOrganizations
has been added to test the listing of projects for multiple organizations.Changes in UI Code:
ui/web-v2/apps/admin/src/proto/environment/service_pb.js
: Various changes were made to accommodate the neworganization_ids
field in theListProjectsRequest
message. These changes include updates to serialization, deserialization, and object conversion methods. [1] [2] [3] [4] [5] [6]