refactor: Code simplification and helper extraction#14
Merged
josemarluedke merged 3 commits intomainfrom Dec 15, 2025
Merged
Conversation
Added NewEmptyPageInfo() constructor to provide a convenient way to create empty PageInfo instances for error cases and empty result sets. Also refactored by splitting models.go into page_args.go and page_info.go to improve code organization and make components easier to locate. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Extracted helper functions to eliminate duplication and improve readability: - cursor/paginator.go: Extracted parsePageArgs helper to consolidate common parameter parsing logic used by New() and BuildFetchParams() - cursor/schema.go: Extracted fixedFieldsToSorts helper to eliminate repeated Sort conversion logic - quotafill/quotafill.go: Extracted argsForEncoder and getSortBy helpers to remove duplicated encoder argument construction - offset/cursor.go: Simplified DecodeCursor with early returns for better control flow - sqlboiler/cursor.go: Consolidated type switch cases to reduce verbosity These changes reduce complexity and improve maintainability without changing any functionality. All tests pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added comprehensive test to verify NewEmptyPageInfo returns correct nil/false values for all PageInfo fields (TotalCount, StartCursor, EndCursor, HasNextPage, HasPreviousPage). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.
Summary
This PR simplifies the codebase by extracting helpers, eliminating duplication, and improving readability. All changes are non-breaking and preserve existing functionality.
Changes
1. File Organization
models.gointopage_args.goandpage_info.gofor better organizationNewEmptyPageInfo()constructor for convenient empty PageInfo creation2. Helper Extraction
cursor/paginator.goparsePageArgs()helper to consolidate duplicate validation logicNew()andBuildFetchParams()now share this codedefaultOrderByandbuildOrderBy()functioncursor/schema.gofixedFieldsToSorts()helper methodquotafill/quotafill.goargsForEncoder()andgetSortBy()helpers3. Code Simplification
offset/cursor.goDecodeCursor()with early return patternsqlboiler/cursor.go4. Test Coverage
NewEmptyPageInfo()Impact
Commits
feat(core): add NewEmptyPageInfo and refactor file organizationrefactor: extract helpers and simplify code across packagestest(core): add test coverage for NewEmptyPageInfo🤖 Generated with Claude Code