Conversation
…ction
parameters
## Summary
Replaced the complex Aliased() method pattern with simplified direct methods
to improve code readability and eliminate the need for function parameters.
## Key Changes
### API Simplification
- Add RetrieveWithAliases() and SummarizeWithAliases() methods to ISummaryService
- Implement simplified methods that internally call Aliased() with appropriate
functions
- Update 10+ call sites across the codebase to use new simplified API
### Before (ceremonious):
```go
summary, err := a.services.Summary().Aliased(
interval[0], interval[1], user,
a.services.Summary().Retrieve, // Function parameter!
filters, end.After(time.Now())
)
After (simplified):
summary, err := a.services.Summary().RetrieveWithAliases(
interval[0], interval[1], user,
filters, end.After(time.Now())
)
Files Modified
- services/services.go: Add new methods to ISummaryService interface
- services/summary.go: Implement RetrieveWithAliases and SummarizeWithAliases
- mocks/summary_service.go: Add mock implementations for new methods
- internal/api/compat_summaries.go: Update GetSummaries endpoint
- internal/api/compat_all_time.go: Update loadUserSummary method
- internal/api/metrics.go: Update multiple summary calls
- services/{goal,report,leaderboard,misc,client}.go: Update service calls
- routes/utils/summary_utils.go: Simplify conditional logic
- services/summary_test.go: Add comprehensive tests for new methods
- SUMMARIES.md: Update documentation with API changes
Benefits
- Eliminated ceremonious function parameters (95% of calls used same pattern)
- Improved code readability and self-documentation
- Reduced cognitive overhead for developers
- Maintained all existing functionality (caching, aliasing, project labels)
- Preserved backward compatibility with existing Aliased() method
- Added comprehensive test coverage
Testing
- All existing tests pass
- Added new tests for RetrieveWithAliases and SummarizeWithAliases methods
- Verified identical behavior to original Aliased() method calls
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
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.
Bugfixes