Skip to content

Fix weighted trade search repeating when exactly 10 results match - #10370

Open
mcagnion wants to merge 1 commit into
PathOfBuildingCommunity:devfrom
mcagnion:bugfix/trade-weight-search-exact-cap
Open

mcagnion wants to merge 1 commit into
PathOfBuildingCommunity:devfrom
mcagnion:bugfix/trade-weight-search-exact-cap

Conversation

@mcagnion

Copy link
Copy Markdown
Contributor

Description of the problem being solved:

When a weighted trade search returns exactly 10 results, SearchWithQueryWeightAdjusted treats it as clipped. It raises the minimum weight, gets fewer than 10 results, lowers the weight again, and repeats until the recursion limit of 5 searches. The final list is correct, but up to 4 extra searches and their fetches count against the trade API rate limit. With a minimum weight of 0 this is pointless, since the whole market already fits in those 10 results.

10 results fill every result slot, which is what #5526 aims for, so the search now stops there (> becomes >=).

Steps taken to verify a working solution:

  • Stubbed the trade search to return exactly 10 results: 5 searches before the change, 1 after, and the 10 results are returned.
  • Traced the other cases (fewer than 10 results, more than 10, clipped at 10000): they take the same path as before.

A search returning exactly maxFetchPerSearch results matched no finalize
condition and was treated as clipped: the threshold was raised, then
halved again, until the recursion limit. A full result window is not
clipped, so fetch it directly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant