BBD-245: Refactor Pager#41
Merged
Merged
Conversation
35f16f5 to
7c8932b
Compare
effervescentia
suggested changes
Sep 22, 2016
Contributor
effervescentia
left a comment
There was a problem hiding this comment.
Looks good otherwise 👍 💭
| this.query.skip(offset); | ||
| this.emit(Events.PAGE_CHANGED, { pageIndex: this.page.pageFromOffset(offset) }); | ||
| this.query.skip(offset - 1); | ||
| this.emit(Events.PAGE_CHANGED, { pageNumber: (Math.ceil(offset / pageSize)) }); |
Contributor
There was a problem hiding this comment.
inner expression doesn't need parentheses
| return Math.ceil(this.fromResult / this.pageSize); | ||
| } | ||
|
|
||
| get previousPage(): number { |
Contributor
There was a problem hiding this comment.
should explicitly put type as number | null for documentation
| return range(0, Math.min(this.finalPage + 1, limit)) | ||
| .map(this.transformPages(limit)); | ||
| get totalRecords(): number { | ||
| // return 0 or null? |
| pageFromOffset(offset: number): number { | ||
| return Math.floor(offset / this.pageSize); | ||
| pageExists(page: number): boolean { | ||
| return (!(page > this.finalPage) && !(page < this.firstPage)); |
Contributor
There was a problem hiding this comment.
simplify to !((page > this.finalPage) || (page < this.firstPage))
Contributor
There was a problem hiding this comment.
your implementation was much nicer
| get hasNext(): boolean { | ||
| return this.step(true) < this.totalRecords; | ||
| pageNumbers(limit: number = 5): number[] { | ||
| const pageRange = range(1, Math.min(this.finalPage + 1, limit + 1)) |
Contributor
There was a problem hiding this comment.
just return it directly
| this.flux.emit(Events.PAGE_CHANGED, { pageNumber: page }); | ||
| return this.flux.search(); | ||
| } | ||
| return Promise.reject(new Error(`page ${page} does not exist`)); |
Contributor
There was a problem hiding this comment.
put the return in an else statement
| expect(this.query.raw.skip).to.eq(13); | ||
| })).prev(); | ||
| describe('pageExists()', () => { | ||
| it('should return true', () => { |
Contributor
There was a problem hiding this comment.
swap the descriptions
Contributor
|
@Vic-Dev also please move the getter |
f comment out all broken tests f f comment out broken tests f f f f f Rename to pageNumber Add pageExists tests Fix merge conflict errors f Can just use current page directly lol
effervescentia
approved these changes
Sep 26, 2016
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.