Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Classes/TradeQueryGenerator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ function TradeQueryGeneratorClass:FinishQuery()
local megalomaniacSpecialMinWeight = self.calcContext.special.itemName == "Megalomaniac" and self.modWeights[#self.modWeights] * 3
-- This Stat diff value will generally be higher than the weighted sum of the same item, because the stats are all applied at once and can thus multiply off each other.
-- So apply a modifier to get a reasonable min and hopefully approximate that the query will start out with small upgrades.
local minWeight = megalomaniacSpecialMinWeight or currentStatDiff * 0.7
local minWeight = megalomaniacSpecialMinWeight or currentStatDiff * 0.5

-- Generate trade query str and open in browser
local filters = 0
Expand Down
34 changes: 20 additions & 14 deletions src/Classes/TradeQueryRequests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ function TradeQueryRequestsClass:SearchWithQueryWeightAdjusted(realm, league, qu
if params.callbackQueryId and response and response.id then
params.callbackQueryId(response.id)
end
if errMsg then
if errMsg and ((errMsg == "No Matching Results Found" and currentRecursion >= maxRecursion) or errMsg ~= "No Matching Results Found") then
return callback(nil, errMsg)
end
if response.total < 10000 or currentRecursion >= maxRecursion then
if (response.total > self.maxFetchPerSearch and response.total < 10000) or currentRecursion >= maxRecursion then
-- Search not clipped or max recursion reached, fetch results and finalize
if previousSearchItems and self.maxFetchPerSearch > response.total then
-- Not enough items in the last search, fill results from previous search
Expand Down Expand Up @@ -144,21 +144,27 @@ function TradeQueryRequestsClass:SearchWithQueryWeightAdjusted(realm, league, qu
self:FetchResults(response.result, response.id, callback)
end
else
-- Search clipped, fetch highest weight item, update query weight and repeat search
previousSearchItemIds = response.result
previousSearchId = response.id
local firstResultBatch = {unpack(response.result, 1, math.min(#response.result, 10))}
self:FetchResults(firstResultBatch, response.id, function(items, errMsg)
if errMsg then
return callback(nil, errMsg)
end
previousSearchItems = items
local highestWeight = items[1].weight
if response.total < self.maxFetchPerSearch then -- Less than maximum items retrieved lower weight to try and get more.
local queryJson = dkjson.decode(query)
queryJson.query.stats[1].value.min = (tonumber(highestWeight) + queryJson.query.stats[1].value.min) / 2
queryJson.query.stats[1].value.min = queryJson.query.stats[1].value.min / 2
query = dkjson.encode(queryJson)
self:PerformSearch(realm, league, query, performSearchCallback)
end)
else -- Search clipped, fetch highest weight item, update query weight and repeat search
previousSearchItemIds = response.result
previousSearchId = response.id
local firstResultBatch = {unpack(response.result, 1, math.min(#response.result, 10))}
self:FetchResults(firstResultBatch, response.id, function(items, errMsg)
if errMsg then
return callback(nil, errMsg)
end
previousSearchItems = items
local highestWeight = items[1].weight
local queryJson = dkjson.decode(query)
queryJson.query.stats[1].value.min = (tonumber(highestWeight) + queryJson.query.stats[1].value.min) / 2
query = dkjson.encode(queryJson)
self:PerformSearch(realm, league, query, performSearchCallback)
end)
end
end
end
self:PerformSearch(realm, league, query, performSearchCallback)
Expand Down