Skip to content

Implement real link usage stats and debugMode logging - #11

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/stats-tracking-and-debug-logging
Aug 3, 2026
Merged

Implement real link usage stats and debugMode logging#11
dmccoystephenson merged 1 commit into
mainfrom
feature/stats-tracking-and-debug-logging

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

  • PersistentData.getTotalUses() and getMostPopularLink() were hardcoded to -1 and "(TBD)". These are now computed from real per-link use counts, and ViewCommand increments a link's use count on each successful lookup. The zero-links case is handled by returning "N/A" for the most popular link.
  • The debugMode config option was documented in CONFIG.md as enabling console logging but had no effect anywhere in the codebase. A debug(String) helper was added to EasyLinks, gated on debugMode, and is now called from ConfigService.setConfigOption and from StorageService's save/load paths.
  • CHANGELOG.md was updated with an Added entry describing both changes.

An unrelated pre-existing gap was noticed during this work: StorageService.save() is never invoked anywhere in the codebase (not even by CreateCommand/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 build
  • mvn test — 8/8 tests pass, including 4 new tests covering getTotalUses and getMostPopularLink (empty-links and multi-link cases)
  • Manual trace of ViewCommand.execute confirms link.setUses(link.getUses() + 1) runs only on a successful lookup, before the label/URL is sent to the player

Closes #9
Closes #8

/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>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric:

  • Scope: PASS — every modified file (EasyLinks.java, ViewCommand.java, PersistentData.java, ConfigService.java, StorageService.java, CHANGELOG.md, PersistentDataTest.java) is necessary for StatsCommand shows placeholder '-1' / '(TBD)' output for uses and most popular link #9 (usage stats) or debugMode config option documented as enabling logging but has no effect #8 (debugMode logging); no unrelated formatting or renames were included.
  • Tests-new: PASS — the two changed public methods (getTotalUses, getMostPopularLink) each have 2 new tests (empty-links case and multi-link case); ViewCommand's use-count increment could not get a dedicated command-level test because this project has no mocking library on the test classpath (only plain JUnit 5) to fake a Bukkit CommandSender, so its correctness is covered indirectly through the PersistentData/Link semantics it relies on.
  • Tests-fix: PASS — reverted PersistentData.java to its pre-fix state (git checkout HEAD~1 -- <path>) and re-ran PersistentDataTest: the 4 new tests failed with the old placeholder values (-1, (TBD)), confirming they are not false negatives. Restored the fix and re-ran: all 8 tests pass.
  • Sibling structure: PASS — new tests follow the existing @BeforeEach/method-under-test-first naming convention already used in PersistentDataTest.
  • Sibling renames: N/A — no parallel-pair identifiers were renamed in this PR.
  • Docs: PASS — CONFIG.md's existing debugMode description ("Enables verbose debug logging to the console") is now accurate; COMMANDS.md/USER_GUIDE.md's generic "View statistics" wording for /el stats required no change; CHANGELOG.md gained an Added entry for both changes.
  • Issue resolution: PASS — StatsCommand shows placeholder '-1' / '(TBD)' output for uses and most popular link #9's named surface area (PersistentData.getTotalUses(), getMostPopularLink(), and the never-called Link.setUses) is now implemented and exercised; debugMode config option documented as enabling logging but has no effect #8's named surface area (debugMode having no effect) is now wired to real logging via EasyLinks.debug(...).
  • CI: PASS — the build check is green on the PR head SHA.
  • Permissions: N/A — no permission node was added or changed; plugin.yml is untouched.

One pre-existing gap noticed but intentionally left out of scope: StorageService.save() is never invoked anywhere in the codebase, so no link data (including use counts) is currently persisted between restarts. This predates this PR and affects CreateCommand/DeleteCommand too, not just the stats feature — a separate tracking issue is being filed for it rather than expanding this PR's scope.

@dmccoystephenson
dmccoystephenson merged commit 42168ae into main Aug 3, 2026
1 check passed
@dmccoystephenson
dmccoystephenson deleted the feature/stats-tracking-and-debug-logging branch August 3, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant