Add shop deal statistics and enhance deal loading logic#28
Merged
Conversation
- introduce ShopDealStats data class to track deal count and total sold items - update DealService to provide loadedDeals as a Collection - implement loadedDealsSnapshot method for easier access to deals - enhance deal loading logic to maintain statistics per shop - refactor ShopService to include methods for retrieving shops by internal ID
There was a problem hiding this comment.
Pull request overview
This pull request refactors the shop/deal service layer to use standard Kotlin Collection types, adds snapshot/lookup APIs for safer access, and introduces per-shop deal statistics to avoid repeated counting/filtering of deals throughout the UI.
Changes:
- Replaced
ObjectSet-based APIs withCollectionplus snapshot + direct lookup methods inShopService/DealService. - Added
ShopDealStatsand implemented stats tracking inDealServiceImpl, updating sorting and item rendering to use the stats. - Updated paper views/utilities to use the new lookup/stats APIs and refreshed caching (Caffeine for shop items).
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| surf-shop-paper/src/main/kotlin/dev/slne/surf/shop/paper/menu/ShopListView.kt | Uses ShopDealStats for display + sorting; updates shop list item creation. |
| surf-shop-paper/src/main/kotlin/dev/slne/surf/shop/paper/menu/OwnShopsListView.kt | Uses ShopDealStats for display + sorting in “own shops” view. |
| surf-shop-paper/src/main/kotlin/dev/slne/surf/shop/paper/menu/edit/storage/ItemStorageRemoveView.kt | Switches to ShopService.getShop lookups when reloading shop state/stock. |
| surf-shop-paper/src/main/kotlin/dev/slne/surf/shop/paper/menu/deal/DoneDealsView.kt | Uses getShopByInternalId for deal->shop resolution. |
| surf-shop-paper/src/main/kotlin/dev/slne/surf/shop/paper/command/argument/ShopArgument.kt | Parses UUID and resolves shops via ShopService.getShop. |
| surf-shop-paper/src/main/kotlin/dev/slne/surf/shop/paper/chest/ShopChestSetupView.kt | Uses ShopService.getShop for current shop resolution. |
| surf-shop-paper/src/main/kotlin/dev/slne/surf/shop/paper/chest/ShopChestSelectShopView.kt | Adds deal stats to rendered shop entries for chest selection. |
| surf-shop-paper/src/main/kotlin/dev/slne/surf/shop/paper/chest/ShopChestListener.kt | Uses ShopService.getShop for shop chest interactions. |
| surf-shop-core/surf-shop-core-paper/src/main/kotlin/dev/slne/surf/shop/core/paper/util/shop-util.kt | Removes per-shop deal counting extensions; adds Caffeine cache for Shop.item. |
| surf-shop-core/surf-shop-core-paper/src/main/kotlin/dev/slne/surf/shop/core/paper/service/ShopServiceImpl.kt | Switches internal storage to ConcurrentHashMap + internalId index; adds lookup helpers. |
| surf-shop-core/surf-shop-core-paper/src/main/kotlin/dev/slne/surf/shop/core/paper/service/DealServiceImpl.kt | Switches to ConcurrentHashMap; maintains per-shop deal stats via merge. |
| surf-shop-core/surf-shop-core-common/src/main/kotlin/dev/slne/surf/shop/core/common/service/ShopService.kt | Updates service API to Collection + snapshot + direct shop lookup methods. |
| surf-shop-core/surf-shop-core-common/src/main/kotlin/dev/slne/surf/shop/core/common/service/DealService.kt | Updates service API to Collection; introduces ShopDealStats + stats lookup. |
| gradle.properties | Bumps project version to 1.3.6. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
This pull request refactors the shop and deal services to improve efficiency, code clarity, and data access patterns. The most notable changes are the replacement of
ObjectSetcollections with standardCollectiontypes, the introduction of snapshot and lookup methods for shops and deals, and the addition of per-shop deal statistics. Several utility and cache implementations have also been updated for better performance and maintainability.Service API and Data Access Improvements:
loadedDealsandloadedShopsfromObjectSettoCollectionin bothDealServiceandShopServiceinterfaces for more flexible and idiomatic Kotlin usage. Added snapshot and direct lookup methods such asloadedDealsSnapshot(),getDealStats(),loadedShopsSnapshot(),getShop(), andgetShopByInternalId(). [1] [2]ConcurrentHashMapfor internal storage, improving concurrency and removing dependency on custom map utilities. [1] [2]putDeal,putShop,removeShop) to manage internal state and maintain additional indexes (e.g., by internal ID). [1] [2]Deal Statistics and Shop Lookup Enhancements:
ShopDealStatsdata class and implemented per-shop deal statistics tracking withgetDealStats(shopInternalId). Updated all relevant code to use these stats instead of manual counting/filtering. [1] [2] [3]getShop()andgetShopByInternalId()methods. [1] [2] [3] [4]Caching and Utility Updates:
itemCachewith a Caffeine cache forShop.item, improving memory management and cache expiration.Code Cleanup and Dependency Removal:
it.unimi.dsi.fastutiland custom utility map/set functions throughout the affected files. [1] [2] [3] [4] [5] [6]These changes collectively make the shop and deal systems more robust, maintainable, and performant.