Aside from the fix looking good, are these two lines actually a good idea (as opposed to throwing an exception)?
As far as I understand this code, if I ask for page -2, it will give me page 1 (instead of the second-last e.g.), and if I ask for page 24 out of 23 it will give me 23. But in both cases, I wouldn't know that I got a different page than I asked for, and that the pages I asked for are invalid, right?
Aside from the fix looking good, are these two lines actually a good idea (as opposed to throwing an exception)?
As far as I understand this code, if I ask for page -2, it will give me page 1 (instead of the second-last e.g.), and if I ask for page 24 out of 23 it will give me 23. But in both cases, I wouldn't know that I got a different page than I asked for, and that the pages I asked for are invalid, right?
bumi
(Migrated from github.com)
reviewed 2019-05-04 08:38:37 +00:00
It is not optimal but 100% fail save. I guess it depends on how we use it (infinite scroll, normal pagination, etc.). The client somehow needs to implement some of the logic no matter what so I guess the wrapper should just return valid data. I don't like to throw an error here right now because error handling is always a pain.
Ideally we would also return some meta data (current page, page count, per page, etc) so the client can better work with it...
It is not optimal but 100% fail save. I guess it depends on how we use it (infinite scroll, normal pagination, etc.). The client somehow needs to implement some of the logic no matter what so I guess the wrapper should just return valid data. I don't like to throw an error here right now because error handling is always a pain.
Ideally we would also return some meta data (current page, page count, per page, etc) so the client can better work with it...
fsmanuel
(Migrated from github.com)
approved these changes 2019-05-07 14:54:11 +00:00
fsmanuel
(Migrated from github.com)
left a comment
Copy Link
Copy Source
🦅
🦅
raucao
(Migrated from github.com)
reviewed 2019-05-07 15:11:57 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
So far it returned 0 because of those in range checks which both
applied because numberOfPages is 0 if we have no record.
@@ -7,3 +7,3 @@number = number < 1 ? 1 : number;number = number > numberOfPages ? numberOfPages : number;number = number < 1 ? 1 : number;Aside from the fix looking good, are these two lines actually a good idea (as opposed to throwing an exception)?
As far as I understand this code, if I ask for page -2, it will give me page 1 (instead of the second-last e.g.), and if I ask for page 24 out of 23 it will give me 23. But in both cases, I wouldn't know that I got a different page than I asked for, and that the pages I asked for are invalid, right?
@@ -7,3 +7,3 @@number = number < 1 ? 1 : number;number = number > numberOfPages ? numberOfPages : number;number = number < 1 ? 1 : number;at least in the zero records case I do not want an exception.
@@ -7,3 +7,3 @@number = number < 1 ? 1 : number;number = number > numberOfPages ? numberOfPages : number;number = number < 1 ? 1 : number;That much is certain. Just asking in general, because I'm not sure it's worth an issue, if I'm not making sense.
@@ -7,3 +7,3 @@number = number < 1 ? 1 : number;number = number > numberOfPages ? numberOfPages : number;number = number < 1 ? 1 : number;not sure when this would happen. - we would need then also proper exception handling on the other sides.
need to pick @fsmanuel's thoughts
@@ -7,3 +7,3 @@number = number < 1 ? 1 : number;number = number > numberOfPages ? numberOfPages : number;number = number < 1 ? 1 : number;It is not optimal but 100% fail save. I guess it depends on how we use it (infinite scroll, normal pagination, etc.). The client somehow needs to implement some of the logic no matter what so I guess the wrapper should just return valid data. I don't like to throw an error here right now because error handling is always a pain.
Ideally we would also return some meta data (current page, page count, per page, etc) so the client can better work with it...
🦅
@@ -7,3 +7,3 @@number = number < 1 ? 1 : number;number = number > numberOfPages ? numberOfPages : number;number = number < 1 ? 1 : number;👍