-
-
Notifications
You must be signed in to change notification settings - Fork 116
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 hasNext
and hasPrevious
properties
#482
Conversation
These properties are similar to the flask-sqlalchemy properties `has_next` and `has_prev`.
Can you add some tests to this? Especially to check the boundaries/edge cases. Like count of 0, trying to pass in a page of -1 etc |
let remainingItems = total - (per * page) | ||
if remainingItems <= 0 { | ||
self.hasNext = false | ||
} else { | ||
self.hasNext = true | ||
} |
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.
How do we feel about one-liners like below?
let remainingItems = total - (per * page) | |
if remainingItems <= 0 { | |
self.hasNext = false | |
} else { | |
self.hasNext = true | |
} | |
self.hasNext = (total - (per * page)) <= 0 | |
self.hasPrevious = page > 1 |
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.
Personally I'd choose the existing code, it's a bit easier to read at a glance. But I don't have a strong opinion on it
Should I add bounds to |
Yes we definitely need tests and count checking for this |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #482 +/- ##
==========================================
+ Coverage 24.78% 24.90% +0.12%
==========================================
Files 149 149
Lines 8660 8670 +10
==========================================
+ Hits 2146 2159 +13
+ Misses 6514 6511 -3
|
Unfortunately, because |
This PR adds the properties
hasNext
andhasPrevious
which are similar to the flask-sqlalchemy propertieshas_next
andhas_prev
.