Skip to content

Commit 5797837

Browse files
committed
trade query result filtering via trader name
1 parent 688f277 commit 5797837

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

src/Classes/TradeQuery.lua

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@ function TradeQueryClass:PriceItemRowDisplay(row_idx, top_pane_alignment_ref, ro
11171117
end
11181118
-- Whisper so we can copy to clipboard
11191119
controls["whisperButton" .. row_idx] = new("ButtonControl",
1120-
{ "TOPLEFT", controls["importButton" .. row_idx], "TOPRIGHT" }, { 8, 0, 185, row_height }, function()
1120+
{ "TOPLEFT", controls["importButton" .. row_idx], "TOPRIGHT" }, { 8, 0, 170, row_height }, function()
11211121
local itemResult = self.itemIndexTbl[row_idx] and self.resultTbl[row_idx][self.itemIndexTbl[row_idx]]
11221122

11231123
if not itemResult then return "" end
@@ -1128,7 +1128,7 @@ function TradeQueryClass:PriceItemRowDisplay(row_idx, top_pane_alignment_ref, ro
11281128
if itemResult.whisper then
11291129
return price and "Whisper for " .. price or "Whisper"
11301130
else
1131-
return price and "Search for selected item"
1131+
return price and "Search for " .. price or "Search"
11321132
end
11331133

11341134
end, function()
@@ -1137,11 +1137,14 @@ function TradeQueryClass:PriceItemRowDisplay(row_idx, top_pane_alignment_ref, ro
11371137
Copy(itemResult.whisper)
11381138
else
11391139
local exactQuery = dkjson.decode(self.lastQuery)
1140-
-- use trade sum to get the specific item. we could also add the
1141-
-- trader name as it is contained in the fetch responses, but
1142-
-- this alone doesn't seem to really result in multiple results.
1143-
-- trade weight min is exclusive while max is inclusive (makes no sense to me)
1144-
exactQuery.query.stats[1].value = { min = tonumber(itemResult.weight) - 0.1, max = tonumber(itemResult.weight) }
1140+
-- use trade sum to get the specific item. both min and max
1141+
-- weight fields seem to be inconsistent. making the minimum
1142+
-- e.g. exactly 172.3 as on the result item does not always work
1143+
exactQuery.query.stats[1].value = { min = floor(itemResult.weight, 1) - 0.1, max = round(itemResult.weight, 1) + 0.1 }
1144+
-- also apply trader name. this should make false positives
1145+
-- extremely unlikely. this doesn't seem to take up a filter
1146+
-- slot
1147+
exactQuery.query.filters.trade_filters = { filters = { account = itemResult.trader } }
11451148

11461149
local exactQueryStr = dkjson.encode(exactQuery)
11471150

src/Classes/TradeQueryRequests.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ function TradeQueryRequestsClass:FetchResultBlock(url, callback)
292292
-- whisper_token = trade_entry.listing.whisper_token,
293293
item_string = common.base64.decode(trade_entry.item.extended.text),
294294
whisper = trade_entry.listing.whisper,
295+
trader = trade_entry.listing.account.name,
295296
weight = trade_entry.item.pseudoMods and trade_entry.item.pseudoMods[1]:match("Sum: (.+)") or "0",
296297
id = trade_entry.id
297298
})

0 commit comments

Comments
 (0)