small scan refactoring
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
Aux = {
|
Aux = {
|
||||||
version = '2.6.19',
|
version = '2.7.0',
|
||||||
blizzard_ui_shown = false,
|
blizzard_ui_shown = false,
|
||||||
orig = {},
|
orig = {},
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -88,7 +88,7 @@ function public.value(item_key)
|
|||||||
local weighted_values = {}
|
local weighted_values = {}
|
||||||
local total_weight = 0
|
local total_weight = 0
|
||||||
for _, data_point in item_record.data_points do
|
for _, data_point in item_record.data_points do
|
||||||
local weight = 0.95^Aux.round((data_point.time - item_record.data_points[1].time) / (60*60*24))
|
local weight = 0.99^Aux.round((data_point.time - item_record.data_points[1].time) / (60*60*24))
|
||||||
total_weight = total_weight + weight
|
total_weight = total_weight + weight
|
||||||
tinsert(weighted_values, {value = data_point.market_value, weight = weight})
|
tinsert(weighted_values, {value = data_point.market_value, weight = weight})
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -107,18 +107,18 @@ function private.owner_data_complete()
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function private.wait_for_callback(args) -- the arguments must not be nil!
|
function private.wait_for_callback(...)
|
||||||
local ok = true
|
local ok = true
|
||||||
|
|
||||||
local f = tremove(args, 1)
|
local f = tremove(arg, 1)
|
||||||
local k = tremove(args)
|
local k = tremove(arg)
|
||||||
|
|
||||||
if f then
|
if f then
|
||||||
tinsert(args, {
|
tinsert(arg, {
|
||||||
suspend = function() ok = false end,
|
suspend = function() ok = false end,
|
||||||
resume = function() ok = true end,
|
resume = function() ok = true end,
|
||||||
})
|
})
|
||||||
f(unpack(args))
|
f(unpack(arg))
|
||||||
end
|
end
|
||||||
|
|
||||||
if ok then
|
if ok then
|
||||||
@@ -128,17 +128,16 @@ function private.wait_for_callback(args) -- the arguments must not be nil!
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function private.scan()
|
function private.scan()
|
||||||
local start_query_index = private.current_thread().params.start_query_index or 1
|
local start_query_index = private.current_thread().params.start_query_index or 1
|
||||||
local next_query_index = private.current_thread().params.next_query_index or function(query_index) return query_index + 1 end
|
local next_query_index = private.current_thread().params.next_query_index or function(query_index) return query_index + 1 end
|
||||||
|
|
||||||
private.current_thread().query_index = private.current_thread().query_index and next_query_index(private.current_thread().query_index) or start_query_index
|
private.current_thread().query_index = private.current_thread().query_index and next_query_index(private.current_thread().query_index) or start_query_index
|
||||||
if private.current_query() then
|
if private.current_query() then
|
||||||
private.wait_for_callback{private.current_thread().params.on_start_query or Aux.util.pass, private.current_thread().query_index, function()
|
private.wait_for_callback(private.current_thread().params.on_start_query, private.current_thread().query_index, function()
|
||||||
private.current_thread().page = private.current_query().start_page
|
private.current_thread().page = private.current_query().start_page
|
||||||
return private.process_query()
|
return private.process_query()
|
||||||
end}
|
end)
|
||||||
else
|
else
|
||||||
local on_complete = private.current_thread().params.on_complete
|
local on_complete = private.current_thread().params.on_complete
|
||||||
threads[private.current_thread().params.type] = nil
|
threads[private.current_thread().params.type] = nil
|
||||||
@@ -156,7 +155,7 @@ function private.process_query()
|
|||||||
|
|
||||||
private.scan_auctions(count, function()
|
private.scan_auctions(count, function()
|
||||||
|
|
||||||
private.wait_for_callback{private.current_thread().params.on_page_scanned or Aux.util.pass, function()
|
private.wait_for_callback(private.current_thread().params.on_page_scanned, function()
|
||||||
if private.current_query().next_page then
|
if private.current_query().next_page then
|
||||||
private.current_thread().page = private.current_query().next_page(private.current_thread().page, private.current_thread().total_pages)
|
private.current_thread().page = private.current_query().next_page(private.current_thread().page, private.current_thread().total_pages)
|
||||||
else
|
else
|
||||||
@@ -168,7 +167,7 @@ function private.process_query()
|
|||||||
else
|
else
|
||||||
return private.scan()
|
return private.scan()
|
||||||
end
|
end
|
||||||
end}
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@@ -196,7 +195,7 @@ function private.scan_auctions_helper(i, n, k)
|
|||||||
Aux.history.process_auction(auction_info)
|
Aux.history.process_auction(auction_info)
|
||||||
|
|
||||||
if not private.current_query().validator or private.current_query().validator(auction_info) then
|
if not private.current_query().validator or private.current_query().validator(auction_info) then
|
||||||
return private.wait_for_callback{private.current_thread().params.on_read_auction or Aux.util.pass, auction_info, recurse}
|
return private.wait_for_callback(private.current_thread().params.on_read_auction, auction_info, recurse)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -231,9 +230,9 @@ function private.submit_query(k)
|
|||||||
local _, total_count = GetNumAuctionItems(private.current_thread().params.type)
|
local _, total_count = GetNumAuctionItems(private.current_thread().params.type)
|
||||||
private.current_thread().total_pages = math.ceil(total_count / PAGE_SIZE)
|
private.current_thread().total_pages = math.ceil(total_count / PAGE_SIZE)
|
||||||
if private.current_thread().total_pages >= private.current_thread().page + 1 then
|
if private.current_thread().total_pages >= private.current_thread().page + 1 then
|
||||||
private.wait_for_callback{private.current_thread().params.on_page_loaded or Aux.util.pass, private.current_thread().page, private.current_thread().total_pages, function()
|
private.wait_for_callback(private.current_thread().params.on_page_loaded, private.current_thread().page, private.current_thread().total_pages, function()
|
||||||
return k()
|
return k()
|
||||||
end}
|
end)
|
||||||
else
|
else
|
||||||
return k()
|
return k()
|
||||||
end
|
end
|
||||||
|
|||||||
+7
-19
@@ -699,6 +699,10 @@ function public.on_load()
|
|||||||
elseif button == 'LeftButton' and IsAltKeyDown() then
|
elseif button == 'LeftButton' and IsAltKeyDown() then
|
||||||
private.popup_info.rename = data.search
|
private.popup_info.rename = data.search
|
||||||
StaticPopup_Show('AUX_SEARCH_SAVED_RENAME')
|
StaticPopup_Show('AUX_SEARCH_SAVED_RENAME')
|
||||||
|
elseif button == 'RightButton' and IsAltKeyDown() then
|
||||||
|
-- unused
|
||||||
|
elseif button == 'LeftButton' and IsControlKeyDown() and st == private.favorite_searches_listing then
|
||||||
|
elseif button == 'RightButton' and IsControlKeyDown() and st == private.favorite_searches_listing then
|
||||||
elseif button == 'LeftButton' then
|
elseif button == 'LeftButton' then
|
||||||
private.search_box:SetText(data.search.filter_string)
|
private.search_box:SetText(data.search.filter_string)
|
||||||
public.start_search()
|
public.start_search()
|
||||||
@@ -713,25 +717,9 @@ function public.on_load()
|
|||||||
end,
|
end,
|
||||||
OnEnter = function(st, data, self)
|
OnEnter = function(st, data, self)
|
||||||
if not data then return end
|
if not data then return end
|
||||||
GameTooltip_SetDefaultAnchor(GameTooltip, UIParent)
|
GameTooltip_SetDefaultAnchor(GameTooltip, UIParent)
|
||||||
GameTooltip:AddLine(gsub(data.search.prettified, ';', '\n\n'), 255/255, 254/255, 250/255, true)
|
GameTooltip:AddLine(gsub(data.search.prettified, ';', '\n\n'), 255/255, 254/255, 250/255, true)
|
||||||
GameTooltip:Show()
|
GameTooltip:Show()
|
||||||
-- GameTooltip:SetOwner(self, 'ANCHOR_RIGHT')
|
|
||||||
-- GameTooltip:AddLine(data.search, 1, 1, 1, true)
|
|
||||||
-- GameTooltip:AddLine("")
|
|
||||||
-- local color = TSMAPI.Design:GetInlineColor("link")
|
|
||||||
-- if st == private.frame.saved.recentST then
|
|
||||||
-- GameTooltip:AddLine(color..'Left-Click to run this search.', 1, 1, 1, true)
|
|
||||||
-- GameTooltip:AddLine(color..'Shift-Left-Click to export this search.', 1, 1, 1, true)
|
|
||||||
-- GameTooltip:AddLine(color..'Ctrl-Left-Click to rename this search.', 1, 1, 1, true)
|
|
||||||
-- GameTooltip:AddLine(color..'Right-Click to favorite this recent search.', 1, 1, 1, true)
|
|
||||||
-- GameTooltip:AddLine(color..'Shift-Right-Click to remove this recent search.', 1, 1, 1, true)
|
|
||||||
-- elseif st == private.frame.saved.favoriteST then
|
|
||||||
-- GameTooltip:AddLine(color..'Left-Click to run this search.', 1, 1, 1, true)
|
|
||||||
-- GameTooltip:AddLine(color..'Shift-Left-Click to export this search.', 1, 1, 1, true)
|
|
||||||
-- GameTooltip:AddLine(color..'Ctrl-Left-Click to rename this search.', 1, 1, 1, true)
|
|
||||||
-- GameTooltip:AddLine(color..'Right-Click to remove from favorite searches.', 1, 1, 1, true)
|
|
||||||
-- end
|
|
||||||
GameTooltip:Show()
|
GameTooltip:Show()
|
||||||
end,
|
end,
|
||||||
OnLeave = function()
|
OnLeave = function()
|
||||||
|
|||||||
Reference in New Issue
Block a user