Skip to content

Add shop deal statistics and enhance deal loading logic#28

Merged
TheBjoRedCraft merged 2 commits into
version/26.1from
perf/optimize-deals
Jun 9, 2026
Merged

Add shop deal statistics and enhance deal loading logic#28
TheBjoRedCraft merged 2 commits into
version/26.1from
perf/optimize-deals

Conversation

@Keviro

@Keviro Keviro commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

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 ObjectSet collections with standard Collection types, 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:

  • Changed loadedDeals and loadedShops from ObjectSet to Collection in both DealService and ShopService interfaces for more flexible and idiomatic Kotlin usage. Added snapshot and direct lookup methods such as loadedDealsSnapshot(), getDealStats(), loadedShopsSnapshot(), getShop(), and getShopByInternalId(). [1] [2]
  • Refactored service implementations to use ConcurrentHashMap for internal storage, improving concurrency and removing dependency on custom map utilities. [1] [2]
  • Added and used helper methods (putDeal, putShop, removeShop) to manage internal state and maintain additional indexes (e.g., by internal ID). [1] [2]

Deal Statistics and Shop Lookup Enhancements:

  • Introduced ShopDealStats data class and implemented per-shop deal statistics tracking with getDealStats(shopInternalId). Updated all relevant code to use these stats instead of manual counting/filtering. [1] [2] [3]
  • Simplified shop lookup throughout the codebase by replacing manual searches with getShop() and getShopByInternalId() methods. [1] [2] [3] [4]

Caching and Utility Updates:

  • Replaced manual itemCache with a Caffeine cache for Shop.item, improving memory management and cache expiration.
  • Updated seller name cache to use Caffeine and improved cache expiration logic.

Code Cleanup and Dependency Removal:

  • Removed unused imports and dependencies on it.unimi.dsi.fastutil and 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.

- 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
@Keviro Keviro self-assigned this Jun 2, 2026
Copilot AI review requested due to automatic review settings June 2, 2026 16:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with Collection plus snapshot + direct lookup methods in ShopService/DealService.
  • Added ShopDealStats and implemented stats tracking in DealServiceImpl, 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.

@TheBjoRedCraft TheBjoRedCraft left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgfm

@TheBjoRedCraft TheBjoRedCraft added this pull request to the merge queue Jun 9, 2026
Merged via the queue into version/26.1 with commit 5a664d6 Jun 9, 2026
@TheBjoRedCraft TheBjoRedCraft deleted the perf/optimize-deals branch June 9, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants