scan bugfix/refactoring
This commit is contained in:
+2
-2
@@ -103,8 +103,8 @@ function public.scan_auctions()
|
||||
private.status_bar:update_status(100 * (page + 1) / total_pages, 100 * (page + 1) / total_pages)
|
||||
private.status_bar:set_text(format('Scanning (Page %d / %d)', page + 1, total_pages))
|
||||
end,
|
||||
on_read_auction = function(auction_info)
|
||||
tinsert(auction_records, auction_info)
|
||||
on_auction = function(auction_record)
|
||||
tinsert(auction_records, auction_record)
|
||||
end,
|
||||
on_complete = function()
|
||||
private.status_bar:update_status(100, 100)
|
||||
|
||||
+1
-1
@@ -123,7 +123,7 @@ function public.scan_bids()
|
||||
private.status_bar:update_status(100 * (page + 1) / total_pages, 100 * (page + 1) / total_pages)
|
||||
private.status_bar:set_text(format('Scanning (Page %d / %d)', page + 1, total_pages))
|
||||
end,
|
||||
on_read_auction = function(auction_record)
|
||||
on_auction = function(auction_record)
|
||||
tinsert(auction_records, auction_record)
|
||||
end,
|
||||
on_complete = function()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Aux = {
|
||||
version = '2.9.8',
|
||||
version = '2.9.9',
|
||||
blizzard_ui_shown = false,
|
||||
orig = {},
|
||||
}
|
||||
|
||||
+8
-8
@@ -886,15 +886,15 @@ function private.refresh_entries()
|
||||
private.status_bar:update_status(100 * (page + 1) / total_pages, 0) -- TODO
|
||||
private.status_bar:set_text(format('Scanning Page %d / %d', page + 1, total_pages))
|
||||
end,
|
||||
on_read_auction = function(auction_info)
|
||||
if auction_info.item_key == item_key then
|
||||
on_auction = function(auction_record)
|
||||
if auction_record.item_key == item_key then
|
||||
private.record_auction(
|
||||
auction_info.item_key,
|
||||
auction_info.aux_quantity,
|
||||
auction_info.unit_blizzard_bid,
|
||||
auction_info.unit_buyout_price,
|
||||
auction_info.duration,
|
||||
auction_info.owner
|
||||
auction_record.item_key,
|
||||
auction_record.aux_quantity,
|
||||
auction_record.unit_blizzard_bid,
|
||||
auction_record.unit_buyout_price,
|
||||
auction_record.duration,
|
||||
auction_record.owner
|
||||
)
|
||||
end
|
||||
end,
|
||||
|
||||
@@ -26,9 +26,13 @@ function private.current_thread()
|
||||
end
|
||||
|
||||
function public.start(params)
|
||||
public.abort(Aux.util.safe_index(threads[params.type], 'id'))
|
||||
if threads[params.type] then
|
||||
public.abort(threads[params.type].id)
|
||||
end
|
||||
|
||||
local thread_id = Aux.control.new_thread(private.scan)
|
||||
local thread_id = Aux.control.new_thread(function()
|
||||
return private.wait_for_callback(private.current_thread().params.on_scan_start, private.scan)
|
||||
end)
|
||||
threads[params.type] = {
|
||||
id = thread_id,
|
||||
params = params,
|
||||
@@ -130,21 +134,19 @@ function private.wait_for_callback(...)
|
||||
end
|
||||
|
||||
function private.scan()
|
||||
private.wait_for_callback(private.current_thread().params.on_start_scan, function()
|
||||
private.current_thread().query_index = private.current_thread().query_index and private.current_thread().query_index + 1 or 1
|
||||
if private.current_query() then
|
||||
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 or 0
|
||||
return private.process_query()
|
||||
end)
|
||||
else
|
||||
local on_complete = private.current_thread().params.on_complete
|
||||
threads[private.current_thread().params.type] = nil
|
||||
if on_complete then
|
||||
return on_complete()
|
||||
end
|
||||
private.current_thread().query_index = private.current_thread().query_index and private.current_thread().query_index + 1 or 1
|
||||
if private.current_query() then
|
||||
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 or 0
|
||||
return private.process_query()
|
||||
end)
|
||||
else
|
||||
local on_complete = private.current_thread().params.on_complete
|
||||
threads[private.current_thread().params.type] = nil
|
||||
if on_complete then
|
||||
return on_complete()
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function private.process_query()
|
||||
@@ -195,7 +197,7 @@ function private.scan_auctions_helper(i, n, k)
|
||||
Aux.history.process_auction(auction_info)
|
||||
|
||||
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, auction_info, recurse)
|
||||
return private.wait_for_callback(private.current_thread().params.on_auction, auction_info, recurse)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+3
-3
@@ -346,13 +346,13 @@ function m.find(auction_record, status_bar, on_abort, on_failure, on_success)
|
||||
status_bar:update_status(0, 0)
|
||||
status_bar:set_text('Searching auction...')
|
||||
end,
|
||||
on_read_auction = function(auction_info, ctrl)
|
||||
if test(auction_info.index) then
|
||||
on_auction = function(auction_record, ctrl)
|
||||
if test(auction_record.index) then
|
||||
found = true
|
||||
ctrl.suspend()
|
||||
status_bar:update_status(100, 100)
|
||||
status_bar:set_text('Auction found')
|
||||
return on_success(auction_info.index)
|
||||
return on_success(auction_record.index)
|
||||
end
|
||||
end,
|
||||
on_abort = function()
|
||||
|
||||
+4
-6
@@ -827,7 +827,7 @@ function public.start_search(filter_string, resume)
|
||||
search_id = Aux.scan.start{
|
||||
type = 'list',
|
||||
queries = queries,
|
||||
on_start_scan = function()
|
||||
on_scan_start = function()
|
||||
private.status_bar:update_status(0,0)
|
||||
private.status_bar:set_text('Scanning auctions...')
|
||||
end,
|
||||
@@ -845,13 +845,12 @@ function public.start_search(filter_string, resume)
|
||||
private.status_bar:update_status(100 * (current_query - 1) / getn(queries), 0) -- TODO
|
||||
private.status_bar:set_text(format('Scanning %d / %d', current_query, getn(queries)))
|
||||
end,
|
||||
on_read_auction = function(auction_info, ctrl)
|
||||
on_auction = function(auction_record)
|
||||
if getn(scanned_records) < 1000 then -- TODO static popup, remove discard
|
||||
tinsert(scanned_records, auction_info)
|
||||
tinsert(scanned_records, auction_record)
|
||||
end
|
||||
end,
|
||||
on_complete = function()
|
||||
private.results_listing:SetDatabase()
|
||||
private.status_bar:update_status(100, 100)
|
||||
private.status_bar:set_text('Done Scanning')
|
||||
|
||||
@@ -863,7 +862,6 @@ function public.start_search(filter_string, resume)
|
||||
end
|
||||
end,
|
||||
on_abort = function()
|
||||
private.results_listing:SetDatabase()
|
||||
private.status_bar:update_status(100, 100)
|
||||
private.status_bar:set_text('Done Scanning')
|
||||
private.stop_button:Hide()
|
||||
@@ -966,7 +964,7 @@ do
|
||||
|
||||
local selection = private.results_listing:GetSelection()
|
||||
if not selection then
|
||||
state = IDLE
|
||||
state = IDLE
|
||||
elseif selection and state == IDLE then
|
||||
private.find_auction(selection.record)
|
||||
elseif state == FOUND and not private.test(selection.record)(found_index) then
|
||||
|
||||
Reference in New Issue
Block a user