refactor: resolve TODOs, optimise queries, and improve shutdown safety#1061
Merged
refactor: resolve TODOs, optimise queries, and improve shutdown safety#1061
Conversation
- Wrap RollbackCommand in transaction for atomicity; restore PlayerReportDeletedEvent firing for reports case - Extract generic cache helpers in RollbackSync using Predicate/Consumer - Add bulk markAllRead() to PlayerWarnStorage, replace N+1 deleteRecent with single DELETE subquery - Replace SELECT-then-loop-delete in PlayerHistoryStorage.purge() with DELETE WHERE IN; batch save() updates with chunked IN clause - Replace in-memory aggregation in getNamesSummary() with SQL GROUP BY - Batch report deletions in PlayerReportStorage while preserving events - Hoist repeated queryForId out of punishAlts loop in CommonJoinListener - Eliminate double isBanned/getBan lookups across listeners and commands - Combine InfoCommand 8 aggregate queries into single UNION ALL subquery - Batch FindAltsCommand per-alt ban record lookups - Batch KickAllCommand kick logging with callBatchTasks - Run PlayerStorage autocomplete async with volatile shutdown guard - Cache permission checks before async blocks in Unban/UnmuteCommand - Add cancelAll() to CommonScheduler; implement in Sponge API 7 and Velocity schedulers tracking only repeating tasks - Introduce typed HistoryEntry replacing HashMap for history methods - Fix ActivityStorage connection management with try-with-resources - Deduplicate HistoryStorage query methods
…markAllRead - RollbackCommandTest: verify reports rollback fires PlayerReportDeletedEvent per report and deletes all matching reports from DB - InfoCommandTest: exercise UNION ALL statistics query with records across all count categories (ban records, mute records, warns, notes, reports) - PlayerWarnStorageTest: verify markAllRead bulk update marks only the target player's unread warnings without affecting other players
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
RollbackCommandoperations inTransactionHelper.runInTransaction()for atomicity, includingRollbackDatacreation inside the transactionPlayerWarnStorage,PlayerHistoryStorage,PlayerReportStorage), replaces in-memory aggregation with SQLGROUP BY/UNION ALL, batches bulk operations with chunkedINclauses, and removes doubleisBanned/getBanlookups across all listeners and commandsPlayerStorageautocomplete setup on an async thread with avolatileshutdown guard, addscancelAll()toCommonSchedulerwith implementations for Sponge API 7 and Velocity (tracking only repeating tasks to prevent unbounded memory growth)RollbackSyncusingPredicate/Consumer, introduces typedHistoryEntryreplacing rawHashMapfor history methods, deduplicatesHistoryStoragequery logic, caches permission checks before async blocks, and fixesActivityStorageconnection management with try-with-resourcesKey changes
RollbackCommandPlayerWarnStorage,PlayerHistoryStorage,PlayerReportStorage,InfoCommand,FindAltsCommand,KickAllCommandUNION ALLcounts, chunked updates, batched insertsCommonJoinListener,CommonChatListener,CommonCommandListener,InfoCommandgetBan()/getMute()call + null checkPlayerStorage,BanManagerPlugin,CommonScheduler,SpongeScheduler,VelocityScheduler,BMSpongePlugin,BMVelocityPlugincancelAll()RollbackSync,HistoryStorage,ActivityStorage,HistoryEntry(new)UnbanCommand,UnmuteCommandrunAsyncBreaking changes
HistoryStoragemethods now returnList<HistoryEntry>instead ofArrayList<HashMap<String, Object>>(internal API, affectsInfoCommandconsumers only)Test plan
./gradlew compileJava— all modules compile successfully./gradlew :BanManagerCommon:test— all 291 tests pass (14 skipped)/bmrollbackwithreportstype firesPlayerReportDeletedEventcorrectly/bminfostatistics display correctly withUNION ALLquery