-
Notifications
You must be signed in to change notification settings - Fork 1k
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
New pagination #162
New pagination #162
Conversation
this.params = options.params; | ||
this.skipFirstItem = false; | ||
|
||
this.params = _.clone(options.params); |
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.
Clone is neat. Why chose this over duplicating the options.params?
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 don't quite follow you here, _.clone
is basically a duplicate?
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.
NM, I googled. Garren, I can't write proper questions. Sorry
Looks as a lot of work! But could you provide some summary what have changed, what does it improved and...why?(: |
Bug: Page sizes 50 and 100 for browsing views doesn't works. Actually, it applies last selected page size or 20. |
// this is really ugly. But we basically need to make sure that | ||
// all parameters are in the correct state and have been parsed before we | ||
// calculate how to paginate the collection | ||
_.each(['startkey', 'endkey', 'key'], function (key) { |
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.
can you pull this out into it's own function?
Another moment: when paginates views, Fauxton adds |
Also, if I set bad value for |
@@ -27,10 +27,14 @@ function require(path, parent, orig) { | |||
// perform real require() |
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.
heh did you update chai too?
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, I was adding tests and realised we needed latest chai. This is stupid to update chai.js while working on a patch. So sorry about that.
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.
haha it's fine. I was just like "wow lotta files changed for pagination"
More notes: it only raises if |
@deathbearbrown hm? |
I think we want to move away from passing the limit parameters in the route fragment. |
@deathbearbrown if so, then Fauxton shouldn't process them. However, I see that you wanted to kill the feature: processing query params from route url allows users to exchange views requests via URL and without talks like: "open view X, click query options, set startkey=Y, endkey=Z, limit=Q, reduce=false and you'll see the result as I do" |
or another case: you configured query for specific view in Fauxton and know wanted to make the same request via curl or whatever client. Just copypaste the URL and remove |
Ack I keep accidentally posting half your name. The API URL button is what is going to show the URL for you to do curl commands, not the fauxton url. |
@kxepal Can you explain what you mean by the 50 and 100 limits not working? |
@garrensmith get it 100% reproduce:
Sorry, no video: just found that gtk-recordMyDesktop generates broken picture. |
Yes, and I was talking about sharing URL with Fauxton with all setted view query parameters. Different things. |
Simon Metson on [email protected], [email protected] replies: |
Simon: I and @garrensmith just discussed this topic in IRC. TL;DR this is could be correct behaviour for Fauxton, but 1) it's not oblivious 2) 90% users will come to Fauxton with Futon experience and such behaviour is completely unexpected for them and could be only recognized as a bug. If so and it's expected, Fauxton shouldn't provide options to select that doesn't works and it should explicitly declare "why functionality which I have used two minutes ago is missed". If you take a look on screen, you'll didn't notice any page size cap. Only 1) if you open Query Options, but it consumes a lot of visible space to keep it always opened 2) if you take a look on URL, but there could be a lot of parameters and @deathbearbrown going to get rid them from there. So, whatever the behavior is, there are some problems with it. |
Simon Metson on [email protected], [email protected] replies: The alternative is removing the limit option, which doesn't solve the problem for other limiting options, or having conditional messaging around the page size. |
Testing this now and nothing is breaking for me. +1? |
This is an improvement and fix on the current pagination. Currently the pagination doesn't work correctly when using startkey, endkey or any of the other query options. It also shows an incorrect value for how many documents are in the view query.
This patch is very large because pagination in Couchdb is quite complex and there are plenty of situations to cater for. This new pagination works quite differently to the previous way we had it working for a user.
A user can set the number of documents they want to view on a page. This is not related to
limit
options in the query options - the limit option is an overall cap of how many documents to paginate too. A limit ofnone
is possible and is the default. If the limit option is set to 50 and a user wants 10 docs per page, the would then be able to paginate 3 pages before hitting the end.Another change is that the api url and browser url does not change when we paginate. That happens internally and hence the new addition of
urlParams
anddocParams
. This allows Fauxton to keep track of the parameters that the user sees and the parameters that the document needs to paginate.The majority of this work is finding the right way to paginate given a variety of query options. This is quite tricky and we had to build up scenarios of different query options and then how to paginate with them.