-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Conversation
codenoid
commented
Oct 16, 2023
server/dashboard/controller.go
Outdated
@@ -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 { |
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.
In my opinion here the check must be way more "strict"... e.g.
if itemsPerPage <= 0 || itemsPerPage > 200 {
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.
done, thankyou
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.
Maybe it's better to create a constant MaxItemsPerPage
and set that to 200
and then use that const in the if condition
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.
done, thankyou
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.
lgtm