bugfix for median

This commit is contained in:
Manuel Simon Hirsig
2016-01-17 11:36:46 +01:00
parent 4ea7aaeb6f
commit 96b4e52eb0
4 changed files with 37 additions and 30 deletions
-1
View File
@@ -1,7 +1,6 @@
## Interface: 11200
## Title: Aux
## Notes: A lightweight addon designed to help manage auctions
## Dependencies: EnhTooltip, Stubby
## SavedVariablesPerCharacter: aux_recently_searched, aux_view, AUX_SELL_SHORTCUT, AUX_BUY_SHORTCUT, AUX_OPEN_SELL, AUX_OPEN_BUY, AUX_INSTANT_BUYOUT, AUX_AUCTION_DURATION
## SavedVariables: aux_database
+31 -28
View File
@@ -30,38 +30,41 @@ function Aux_OnLoad()
Aux.log('Aux v'..AuxVersion..' loaded.')
Aux.loaded = true
tinsert(UISpecialFrames, 'AuxFrame')
Stubby.RegisterFunctionHook('EnhTooltip.AddTooltip', 100, function(_ ,_ ,_ ,_ , link, _, count)
local item_id, suffix_id = EnhTooltip.BreakLink(link)
local item_key = item_id..':'..suffix_id
LoadAddOn('EnhTooltip')
if IsAddOnLoaded('EnhTooltip') then
Stubby.RegisterFunctionHook('EnhTooltip.AddTooltip', 100, function(_ ,_ ,_ ,_ , link, _, count)
local item_id, suffix_id = EnhTooltip.BreakLink(link)
local item_key = item_id..':'..suffix_id
local auction_count, seen_days, daily_average, EMA3, EMA7, EMA14 = Aux.stat_average.get_price_data(item_key)
local auction_count, seen_days, daily_average, EMA3, EMA7, EMA14 = Aux.stat_average.get_price_data(item_key)
if auction_count == 0 then
EnhTooltip.AddLine('Never seen at auction', nil, true)
EnhTooltip.LineColor(0.5, 0.8, 0.5)
else
EnhTooltip.AddLine('Seen '..auction_count..' '..Aux_PluralizeIf('time', auction_count)..' at auction', nil, true)
EnhTooltip.LineColor(0.5, 0.8, 0.1)
local median = Aux.stat_histogram.get_price_data(item_key)
if count == 1 then
EnhTooltip.AddLine('Median: '..Aux.util.money_string(median), nil, true)
if auction_count == 0 then
EnhTooltip.AddLine('Never seen at auction', nil, true)
EnhTooltip.LineColor(0.5, 0.8, 0.5)
else
EnhTooltip.AddLine('Median: '..Aux.util.money_string(median * count)..' ('..Aux.util.money_string(median)..' ea.)', nil, true)
end
EnhTooltip.LineColor(0.1,0.8,0.5)
EnhTooltip.AddLine('Seen '..auction_count..' '..Aux_PluralizeIf('time', auction_count)..' at auction', nil, true)
EnhTooltip.LineColor(0.5, 0.8, 0.1)
-- EnhTooltip.AddLine('AVG TDA: '..(daily_average > 0 and Aux.util.money_string(daily_average) or RED_FONT_COLOR_CODE..'n/a'..FONT_COLOR_CODE_CLOSE), nil, true)
-- EnhTooltip.LineColor(0.1,0.8,0.5)
-- EnhTooltip.AddLine('EMA3: '..(EMA3 > 0 and Aux.util.money_string(EMA3) or RED_FONT_COLOR_CODE..'n/a'..FONT_COLOR_CODE_CLOSE), nil, true)
-- EnhTooltip.LineColor(0.1,0.8,0.5)
-- EnhTooltip.AddLine('EMA7: '..(EMA7 > 0 and Aux.util.money_string(EMA7) or RED_FONT_COLOR_CODE..'n/a'..FONT_COLOR_CODE_CLOSE), nil, true)
-- EnhTooltip.LineColor(0.1,0.8,0.5)
-- EnhTooltip.AddLine('EMA14: '..(EMA14 > 0 and Aux.util.money_string(EMA14) or RED_FONT_COLOR_CODE..'n/a'..FONT_COLOR_CODE_CLOSE), nil, true)
-- EnhTooltip.LineColor(0.1,0.8,0.5)
end
end)
local median = Aux.stat_histogram.get_price_data(item_key)
if count == 1 then
EnhTooltip.AddLine('Median: '..Aux.util.money_string(median), nil, true)
else
EnhTooltip.AddLine('Median: '..Aux.util.money_string(median * count)..' ('..Aux.util.money_string(median)..' ea.)', nil, true)
end
EnhTooltip.LineColor(0.1,0.8,0.5)
-- EnhTooltip.AddLine('AVG TDA: '..(daily_average > 0 and Aux.util.money_string(daily_average) or RED_FONT_COLOR_CODE..'n/a'..FONT_COLOR_CODE_CLOSE), nil, true)
-- EnhTooltip.LineColor(0.1,0.8,0.5)
-- EnhTooltip.AddLine('EMA3: '..(EMA3 > 0 and Aux.util.money_string(EMA3) or RED_FONT_COLOR_CODE..'n/a'..FONT_COLOR_CODE_CLOSE), nil, true)
-- EnhTooltip.LineColor(0.1,0.8,0.5)
-- EnhTooltip.AddLine('EMA7: '..(EMA7 > 0 and Aux.util.money_string(EMA7) or RED_FONT_COLOR_CODE..'n/a'..FONT_COLOR_CODE_CLOSE), nil, true)
-- EnhTooltip.LineColor(0.1,0.8,0.5)
-- EnhTooltip.AddLine('EMA14: '..(EMA14 > 0 and Aux.util.money_string(EMA14) or RED_FONT_COLOR_CODE..'n/a'..FONT_COLOR_CODE_CLOSE), nil, true)
-- EnhTooltip.LineColor(0.1,0.8,0.5)
end
end)
end
end
function Aux_OnEvent()
+4
View File
@@ -8,5 +8,9 @@ function SlashCmdList.AUX(parameter)
elseif parameter == 'clear database' then
aux_database = {}
Aux.log('Database cleared.')
elseif parameter == 'clear' then
aux_database = {}
Aux.persistence.load_dataset().snapshot = {}
Aux.log('Snapshot and database cleared.')
end
end
+2 -1
View File
@@ -117,6 +117,7 @@ function public.process_auction(auction_info)
end
local index = ceil(buyout / private.current_record.step)
snipe.log(private.current_record.step..'X'..auction_info.item_id)
if private.current_record.count <= 20 then
@@ -203,7 +204,7 @@ function private.refactor(pmax, precision)
private.current_record.min = new_min
private.current_record.max = new_max
private.current_record.max = new_step
private.current_record.step = new_step
private.current_record.count = new_count
private.current_record.values = new_values
end