-
Notifications
You must be signed in to change notification settings - Fork 702
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
Add pagination for direct-helm get summaries. #3091
Conversation
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.
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() |
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.
Mmm, so this way is the most idiomatic way to check nulls? Interesting
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.
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 |
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.
Great, so atm, it is just the same old behavior we already implemented.
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.
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)) |
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.
Is it always 3
?
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.
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
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.
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() |
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.
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 |
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.
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)) |
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.
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
Signed-off-by: Michael Nelson <minelson@vmware.com>
Description of the change
Adds and tests pagination for direct helm plugin's GetAvailablePackageSummaries request.
Applicable issues