Skip to content
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

feat(boards2): add pagination #3216

Open
wants to merge 8 commits into
base: devx/feature/boardsv2
Choose a base branch
from

Conversation

x1unix
Copy link

@x1unix x1unix commented Nov 27, 2024

This PR adds pagination for boards and posts list using p/demo/avl/pager package.

Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests

CC @jeronimoalbi

@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Nov 27, 2024
@x1unix x1unix changed the base branch from master to devx/feature/boardsv2 November 27, 2024 04:27
Copy link

codecov bot commented Nov 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

Comment on lines +113 to +114
pg := pager.NewPager(&board.threads, p.PageSize)
page := pg.GetPage(p.PageNumber)
Copy link
Member

@jeronimoalbi jeronimoalbi Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not possible to use something like the following?

Suggested change
pg := pager.NewPager(&board.threads, p.PageSize)
page := pg.GetPage(p.PageNumber)
page := pager.NewPager(&board.threads, boardsPageSize).MustGetPageByPath(path)

Where path is the render path. This would allow to remove the Pagination struct.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeronimoalbi the idea here is to have separation of concerns, so render.gno which acts as a controller will be responsible for getting pagination query string information.

Comment on lines 33 to 39
pg := pager.NewPager(&gBoardsByID, defaultPageSize)
pageNum, limit, err := pg.ParseQuery(r.requestUri)
if err != nil {
panic(err)
}

page := pg.GetPageWithSize(pageNum, limit)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@x1unix what do you think about just using MustGetPageByPath everywhere? Is there a constraint not to use it also here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeronimoalbi please check response above.

@jeronimoalbi
Copy link
Member

@x1unix let's not wrap the router, lets use it even if it doesn't support query string arguments. At this point is not a blocker as the listing will work, caveat is that only the first page for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧾 package/realm Tag used for new Realms or Packages.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants