Repository navigation
fix: count cross-account flips in the account-wide totals - #115
Merged
Merged
Conversation
countFlipQuantity summed min(bought, sold) per account, so items bought on one account and sold on another were never counted as flipped. Players who funnel items across their own accounts (alts buying to bypass the ge limit, a main selling) saw massively undercounted account-wide totals: for a reported earth rune player (1.9b bought at 4gp across alts, 1.28b sold at 5gp on the main) the panel showed 125,999,310 flipped and 126M gp profit instead of 1,283,457,544 flipped and ~1.28b gp profit. - take min(items bought, items sold) across the whole tradelist again, which also drops the per-account grouping allocation (measured ~4x faster per recompute at that player's 133k-offer scale) - getFlips still matches offers per account, so the trade history tab is unchanged; only the totals (profit, quantity flipped, roi, sorting) now aggregate across the player's accounts - regression test assembles the reported scenario through the real account-wide merge pipeline; HistoryTotalsTest now expects funneled items to match across accounts
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
AntonyGarand
marked this pull request as ready for review
October 21, 2026 15:10
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.
Problem
A player with many alts funneling earth runes across accounts reported wrong account-wide totals: alts bought runes at 4 gp, a main sold them at 5 gp — 1,907,078,609 bought and 1,283,457,544 sold in total. Profit ea (1 gp) and ROI (25%) looked right, but the totals were ~10x too small:
Root cause
HistoryManager.countFlipQuantity(changed in 4374bfa) grouped the merged account-wide offer list by account and summedmin(bought, sold)per account. For this player the alts never sold (min = 0each) and the main had bought only 125,999,310 runes itself, so that within-account min is exactly the 125,999,310 "Quantity Flipped" shown in the report — every rune bought on an alt and sold on the main was invisible to the totals.getValueOfMatchedOfferscaps revenue/expense at the same quantity, so Total Profit collapsed with it, while per-item ratios stayed correct.Fix
Take
min(items bought, items sold)across the whole tradelist again, so surplus inventory is shared between the player's own accounts in the account-wide view. Single-account views are unaffected (all their offers belong to one account).getFlipsstill matches offers per account, so the trade history / flips tab is unchanged — only the aggregate totals (total profit, quantity flipped, ROI, and the profit/flip-count sort options) now aggregate across accounts.HistoryTotalsTest.accountWideQuantityWidensTheSumWithoutSharingUnmatchedInventorypinned the old per-account semantics; it now expects funneled items to match across accounts (renamed toaccountWideQuantityMatchesItemsFunnelledAcrossAccounts). This is a deliberate behavior change — flagging it in case the old semantics were intentional for some workflow I'm not aware of.Tests
AccountWideCrossAccountFlipsTestreproduces the reported scenario through the real account-wide pipeline (per-account hydratedFlippingItems merged withFlippingItem::merge, stats computed exactly likeFlippingItemPanel.updateLabels). Both total assertions failed on master with the exact reported numbers and pass now; the label test pins bought/sold/avg prices/profit-ea/ROI.