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: Add pagination to /devices/list #236

Merged
merged 9 commits into from
Feb 19, 2025
Merged

feat: Add pagination to /devices/list #236

merged 9 commits into from
Feb 19, 2025

Conversation

razor-x
Copy link
Member

@razor-x razor-x commented Feb 14, 2025

No description provided.

@seambot
Copy link
Contributor

seambot commented Feb 14, 2025

Bundle dist size: 26M

@razor-x razor-x requested a review from mikewuu February 14, 2025 00:54
@@ -52,7 +83,38 @@ export default withRouteSpec({
)
}

devices = sortBy(devices, ["created_at", "device_id"])
Copy link

Choose a reason for hiding this comment

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

shouldn't we do this in the db level?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but I did this intentionally here for now as we will need to factor all of this core logic out for pagination support on all endpoints. As part of that, every query will need to ensure it's ordered.

page_cursor: z
.string()
.optional()
.nullable()
Copy link

Choose a reason for hiding this comment

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

why nullable? What case the client passes null in this field?

Copy link
Member Author

Choose a reason for hiding this comment

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

It makes type DX much better, otherwise users have to use "?? undefined" or add null checks. But null / undefined are basically the same here.

Copy link
Member Author

razor-x commented Feb 18, 2025

I found nullable is easier for type DX. There is no functional difference in this case and otherwise you have to do a lot of ?? undefined

@razor-x razor-x changed the title Add pagination to /devices/list feat: Add pagination to /devices/list Feb 19, 2025
@razor-x razor-x merged commit c8de36a into main Feb 19, 2025
20 checks passed
@razor-x razor-x deleted the paginate-devices-list branch February 19, 2025 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants