-
Notifications
You must be signed in to change notification settings - Fork 159
feat: add show more for outermost dimension in pivot #8570
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
Open
djbarnwal
wants to merge
3
commits into
main
Choose a base branch
from
feat/outer-show-more-pivot
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
122 changes: 122 additions & 0 deletions
122
web-common/src/features/dashboards/pivot/tests/pivot-constants.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| import { | ||
| calculateEffectiveRowLimit, | ||
| getNextRowLimit, | ||
| getNextLimitLabel, | ||
| } from "@rilldata/web-common/features/dashboards/pivot/pivot-constants"; | ||
| import { describe, it, expect } from "vitest"; | ||
|
|
||
| describe("calculateEffectiveRowLimit", () => { | ||
| describe("with respectPageSize=true (default)", () => { | ||
| it("returns pageSize when rowLimit is undefined", () => { | ||
| expect(calculateEffectiveRowLimit(undefined, 0, 50)).toBe("50"); | ||
| expect(calculateEffectiveRowLimit(undefined, 10, 50)).toBe("50"); | ||
| }); | ||
|
|
||
| it("returns 0 when remainingRows is 0 or negative", () => { | ||
| expect(calculateEffectiveRowLimit(50, 50, 50)).toBe("0"); | ||
| expect(calculateEffectiveRowLimit(50, 60, 50)).toBe("0"); | ||
| }); | ||
|
|
||
| it("returns min of remainingRows and pageSize when both are positive", () => { | ||
| // remainingRows < pageSize | ||
| expect(calculateEffectiveRowLimit(30, 0, 50)).toBe("30"); | ||
| expect(calculateEffectiveRowLimit(100, 80, 50)).toBe("20"); | ||
|
|
||
| // remainingRows > pageSize | ||
| expect(calculateEffectiveRowLimit(100, 0, 50)).toBe("50"); | ||
| expect(calculateEffectiveRowLimit(150, 50, 50)).toBe("50"); | ||
|
|
||
| // remainingRows == pageSize | ||
| expect(calculateEffectiveRowLimit(50, 0, 50)).toBe("50"); | ||
| }); | ||
|
|
||
| it("handles pagination correctly with rowOffset", () => { | ||
| const rowLimit = 100; | ||
| const pageSize = 50; | ||
|
|
||
| // First page | ||
| expect(calculateEffectiveRowLimit(rowLimit, 0, pageSize)).toBe("50"); | ||
|
|
||
| // Second page | ||
| expect(calculateEffectiveRowLimit(rowLimit, 50, pageSize)).toBe("50"); | ||
|
|
||
| // Third page (only 10 rows left) | ||
| expect(calculateEffectiveRowLimit(rowLimit, 90, pageSize)).toBe("10"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("with respectPageSize=false", () => { | ||
| it("returns pageSize when rowLimit is undefined", () => { | ||
| expect(calculateEffectiveRowLimit(undefined, 0, 50, false)).toBe("50"); | ||
| }); | ||
|
|
||
| it("returns 0 when remainingRows is 0 or negative", () => { | ||
| expect(calculateEffectiveRowLimit(50, 50, 50, false)).toBe("0"); | ||
| expect(calculateEffectiveRowLimit(50, 60, 50, false)).toBe("0"); | ||
| }); | ||
|
|
||
| it("returns full remainingRows without pageSize constraint", () => { | ||
| // This is the key difference - no min() with pageSize | ||
| expect(calculateEffectiveRowLimit(100, 0, 50, false)).toBe("100"); | ||
| expect(calculateEffectiveRowLimit(75, 0, 50, false)).toBe("75"); | ||
| expect(calculateEffectiveRowLimit(150, 0, 50, false)).toBe("150"); | ||
| }); | ||
|
|
||
| it("handles offset correctly without pageSize constraint", () => { | ||
| expect(calculateEffectiveRowLimit(100, 20, 50, false)).toBe("80"); | ||
| expect(calculateEffectiveRowLimit(100, 50, 50, false)).toBe("50"); | ||
| expect(calculateEffectiveRowLimit(100, 90, 50, false)).toBe("10"); | ||
| }); | ||
|
|
||
| it("allows fetching more than one page at once", () => { | ||
| // When user clicks "Show more" to 100, we want to fetch all 100 rows | ||
| // not just 50 (one page) | ||
| expect(calculateEffectiveRowLimit(100, 0, 50, false)).toBe("100"); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| describe("getNextRowLimit", () => { | ||
| it("returns next limit in progression: 5 → 10 → 25 → 50 → 100", () => { | ||
| expect(getNextRowLimit(5)).toBe(10); | ||
| expect(getNextRowLimit(10)).toBe(25); | ||
| expect(getNextRowLimit(25)).toBe(50); | ||
| expect(getNextRowLimit(50)).toBe(100); | ||
| }); | ||
|
|
||
| it("returns undefined when at or beyond 100", () => { | ||
| expect(getNextRowLimit(100)).toBeUndefined(); | ||
| expect(getNextRowLimit(150)).toBeUndefined(); | ||
| }); | ||
|
|
||
| it("finds next higher value when current limit is not in progression", () => { | ||
| expect(getNextRowLimit(7)).toBe(10); | ||
| expect(getNextRowLimit(15)).toBe(25); | ||
| expect(getNextRowLimit(30)).toBe(50); | ||
| expect(getNextRowLimit(60)).toBe(100); | ||
| }); | ||
|
|
||
| it("handles edge cases", () => { | ||
| expect(getNextRowLimit(1)).toBe(5); | ||
| expect(getNextRowLimit(99)).toBe(100); | ||
| }); | ||
| }); | ||
|
|
||
| describe("getNextLimitLabel", () => { | ||
| it("returns string representation of next limit", () => { | ||
| expect(getNextLimitLabel(5)).toBe("10"); | ||
| expect(getNextLimitLabel(10)).toBe("25"); | ||
| expect(getNextLimitLabel(25)).toBe("50"); | ||
| expect(getNextLimitLabel(50)).toBe("100"); | ||
| }); | ||
|
|
||
| it("returns '100' when at or beyond max limit", () => { | ||
| expect(getNextLimitLabel(100)).toBe("100"); | ||
| expect(getNextLimitLabel(150)).toBe("100"); | ||
| }); | ||
|
|
||
| it("handles non-standard limits", () => { | ||
| expect(getNextLimitLabel(7)).toBe("10"); | ||
| expect(getNextLimitLabel(30)).toBe("50"); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
While this is removing the extra dimension for nested query it is still displayed in the table. Are we missing code to remove it from the display list?