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

Add pagination for direct-helm get summaries. #3091

Conversation

absoludity
Copy link
Contributor

Description of the change

Adds and tests pagination for direct helm plugin's GetAvailablePackageSummaries request.

Applicable issues

Copy link
Contributor

@antgamdia antgamdia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooops, I forgot to submit the review yesterday 🤦 Sorry!
Thanks for the changes here! Happy to finally see the pagination!

@@ -149,8 +150,12 @@ func (s *Server) GetAvailablePackageSummaries(ctx context.Context, request *core
cq.AppVersion = request.FilterOptions.AppVersion
}

// TODO: We are not yet returning paginated results here
charts, _, err := s.manager.GetPaginatedChartListWithFilters(cq, 1, 0)
pageSize := request.GetPaginationOptions().GetPageSize()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm, so this way is the most idiomatic way to check nulls? Interesting

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, though it's specific to the grpc message generation, which provides these getters that initialise to the default (empty) struct.

}, nil
}

// pageOffsetFromPageToken converts a page token to an integer offset
// representing the page of results.
// TODO(mnelson): When aggregating results from different plugins, we'll
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, so atm, it is just the same old behavior we already implemented.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. And we can leave it that way until we're updating to built-in cache support for plugins, I'd think.

if tc.request.GetPaginationOptions().GetPageSize() > 0 {
mock.ExpectQuery("SELECT count").
WithArgs(tc.request.Context.Namespace, tc.server.globalPackagingNamespace).
WillReturnRows(sqlmock.NewRows([]string{"count"}).AddRow(3))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it always 3 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's a query in the assetsvc that returns the total pages (so counts the filtered but not paginated set): https://github.com/kubeapps/kubeapps/blob/master/cmd/assetsvc/pkg/utils/postgresql_utils.go#L80

Copy link
Contributor Author

@absoludity absoludity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooops, I forgot to submit the review yesterday facepalm Sorry!

No worries - done the same many times :) Thanks!

@@ -149,8 +150,12 @@ func (s *Server) GetAvailablePackageSummaries(ctx context.Context, request *core
cq.AppVersion = request.FilterOptions.AppVersion
}

// TODO: We are not yet returning paginated results here
charts, _, err := s.manager.GetPaginatedChartListWithFilters(cq, 1, 0)
pageSize := request.GetPaginationOptions().GetPageSize()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, though it's specific to the grpc message generation, which provides these getters that initialise to the default (empty) struct.

}, nil
}

// pageOffsetFromPageToken converts a page token to an integer offset
// representing the page of results.
// TODO(mnelson): When aggregating results from different plugins, we'll
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. And we can leave it that way until we're updating to built-in cache support for plugins, I'd think.

if tc.request.GetPaginationOptions().GetPageSize() > 0 {
mock.ExpectQuery("SELECT count").
WithArgs(tc.request.Context.Namespace, tc.server.globalPackagingNamespace).
WillReturnRows(sqlmock.NewRows([]string{"count"}).AddRow(3))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's a query in the assetsvc that returns the total pages (so counts the filtered but not paginated set): https://github.com/kubeapps/kubeapps/blob/master/cmd/assetsvc/pkg/utils/postgresql_utils.go#L80

@absoludity absoludity merged commit 2369f76 into vmware-tanzu:master Jul 7, 2021
@absoludity absoludity deleted the 2993-pagination-get-available-pkg-summary-3 branch July 7, 2021 00:28
absoludity added a commit to absoludity/kubeapps that referenced this pull request Jul 8, 2021
Signed-off-by: Michael Nelson <minelson@vmware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants