Allow /at top to accept an optional number of players - #83
Merged
Conversation
- Add ActivityRecordService.getTopRecords(int count); getTopTenRecords() now delegates to it - Parse and validate an optional count argument in TopCommand (1-100, default 10) - Add /at top (number) to the in-game help output - Document the argument in COMMANDS.md, USER_GUIDE.md and CHANGELOG.md - Add JUnit 5 tests for TopCommand argument handling and ActivityRecordService.getTopRecords Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Member
Author
Self-reviewRubric scored against the diff and command output, not from memory.
Judgment calls left for a reviewer
This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). |
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
/at topnow accepts an optional number argument (/at top 25); the default remains 10 and the maximum accepted value is 100, so a single command cannot flood chat with an unbounded leaderboard.ActivityRecordService.getTopRecords(int count)was added, andgetTopTenRecords()now delegates to it. The existing REST leaderboard endpoint keeps callinggetTopTenRecords(), so its behavior and documented response shape are unchanged./at average: a non-numeric argument, zero or a negative number, and a number above 100 are each rejected with a red message and no leaderboard output.COMMANDS.md,USER_GUIDE.mdandCHANGELOG.mdwere updated to describe the new argument.Closes #38
Test plan
mvn -B test— 47 tests run, 0 failures (33 pre-existing plus 14 new).TopCommandTest(new, JUnit 5): default of 10 with no argument and via the sender-only overload, the requested count for a valid argument, the boundary value 100, and rejection ofabc,0,-5and101with the service never consulted.ActivityRecordServiceTest(new, JUnit 5): ordering by hours descending, the requested count honored, fewer records than requested, zero requested, a negative count propagatingIllegalArgumentExceptionfrom the algorithm, andgetTopTenRecords()still capping at 10.Notes on test scope
New tests were written against JUnit 5 deliberately: the JUnit 4 classes in this repository are not currently executed by Surefire, which is filed separately as #80. A timing-flaky assertion observed while investigating that is filed as #81, and a
CONTRIBUTING.mdreference to a non-existentdevelopbranch is filed as #82. None of the three is addressed here, to keep this change scoped to #38 and out ofpom.xml.Deferred this cycle
The remaining open issues were not picked up, for the reasons below:
This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).