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

query result: implement pagination #97

Merged
merged 5 commits into from
Oct 17, 2023
Merged

query result: implement pagination #97

merged 5 commits into from
Oct 17, 2023

Conversation

codenoid
Copy link
Contributor

image

@@ -243,6 +247,31 @@ func dashboardResultHandler(r *http.Request, w http.ResponseWriter, client *mong
filter, findOptions := buildReturnQuery(query)
// Sort by `timestamp` field descending.
findOptions.SetSort(bson.D{{Key: "timestamp", Value: -1}})

itemsPerPage, _ := strconv.ParseInt(query.Get("limit"), 10, 64)
if itemsPerPage == 0 {
Copy link
Owner

@edoardottt edoardottt Oct 17, 2023

Choose a reason for hiding this comment

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

In my opinion here the check must be way more "strict"... e.g.

if itemsPerPage <= 0 || itemsPerPage > 200 {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, thankyou

Copy link
Owner

Choose a reason for hiding this comment

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

Maybe it's better to create a constant MaxItemsPerPage and set that to 200 and then use that const in the if condition

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, thankyou

server/dashboard/controller.go Show resolved Hide resolved
server/dashboard/controller.go Dismissed Show dismissed Hide dismissed
@edoardottt edoardottt changed the base branch from main to devel October 17, 2023 07:22
@edoardottt edoardottt self-requested a review October 17, 2023 07:45
Copy link
Owner

@edoardottt edoardottt left a comment

Choose a reason for hiding this comment

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

lgtm

@edoardottt edoardottt merged commit 09daf7d into edoardottt:devel Oct 17, 2023
5 checks passed
@edoardottt edoardottt linked an issue Oct 17, 2023 that may be closed by this pull request
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add pagination to query results
2 participants