Implement real link usage stats and debugMode logging - #11
Merged
Conversation
/el stats previously printed hardcoded placeholder values for total uses and most popular link. PersistentData now sums real per-link use counts (incremented by ViewCommand on lookup) and picks the label with the highest count. Also wires the documented but inert debugMode config option to actual console logging at config-set and storage load/save points. Closes #9 Closes #8 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Member
Author
|
Self-review rubric:
One pre-existing gap noticed but intentionally left out of scope: |
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
PersistentData.getTotalUses()andgetMostPopularLink()were hardcoded to-1and"(TBD)". These are now computed from real per-link use counts, andViewCommandincrements a link's use count on each successful lookup. The zero-links case is handled by returning"N/A"for the most popular link.debugModeconfig option was documented inCONFIG.mdas enabling console logging but had no effect anywhere in the codebase. Adebug(String)helper was added toEasyLinks, gated ondebugMode, and is now called fromConfigService.setConfigOptionand fromStorageService's save/load paths.CHANGELOG.mdwas updated with anAddedentry describing both changes.An unrelated pre-existing gap was noticed during this work:
StorageService.save()is never invoked anywhere in the codebase (not even byCreateCommand/DeleteCommand), so link data — including use counts — is not currently persisted across restarts. That gap is outside the scope of the two issues closed here, so a separate tracking issue is being filed rather than folding a fix into this PR.This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
Test plan
mvn compile— clean buildmvn test— 8/8 tests pass, including 4 new tests coveringgetTotalUsesandgetMostPopularLink(empty-links and multi-link cases)ViewCommand.executeconfirmslink.setUses(link.getUses() + 1)runs only on a successful lookup, before the label/URL is sent to the playerCloses #9
Closes #8