post settings improved
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
## Interface: 11200
|
||||
## Title: Aux
|
||||
## SavedVariablesPerCharacter: aux_recent_searches, aux_favorite_searches
|
||||
## SavedVariables: aux_database, aux_auctionable_items, aux_auctionable_item_ids, aux_post_mode, aux_price_per_unit, aux_tooltip_daily
|
||||
## SavedVariables: aux_datasets, aux_auctionable_items, aux_auctionable_item_ids, aux_post_mode, aux_price_per_unit, aux_tooltip_daily
|
||||
|
||||
slash.lua
|
||||
core.xml
|
||||
|
||||
+4
-4
@@ -197,12 +197,12 @@ local methods = {
|
||||
GetRecordPercent = function(self, record)
|
||||
if not record then return end
|
||||
-- cache the market value on the record
|
||||
record.historical_value = record.historical_value or Aux.history.value(record.item_key) or 0
|
||||
if record.historical_value > 0 then
|
||||
local historical_value = Aux.history.value(record.item_key) or 0
|
||||
if historical_value > 0 then
|
||||
if record.unit_buyout_price > 0 then
|
||||
return Aux.round(100 * record.unit_buyout_price / record.historical_value, 1)
|
||||
return Aux.round(100 * record.unit_buyout_price / historical_value, 1)
|
||||
end
|
||||
return nil, Aux.round(100 * record.unit_bid_price / record.historical_value, 1)
|
||||
return nil, Aux.round(100 * record.unit_bid_price / historical_value, 1)
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
+20
-32
@@ -1,6 +1,8 @@
|
||||
local private, public = {}, {}
|
||||
Aux.history = public
|
||||
|
||||
private.value_cache = {}
|
||||
|
||||
function private.next_push()
|
||||
local date = date('*t')
|
||||
date.hour, date.min, date.sec = 24, 0, 0
|
||||
@@ -17,25 +19,6 @@ function private.load_data()
|
||||
return dataset.history
|
||||
end
|
||||
|
||||
function public.test()
|
||||
local data = private.load_data()
|
||||
for key, _ in data do
|
||||
local record = private.read_record(key)
|
||||
record.next_push = 0
|
||||
private.write_record(key, record)
|
||||
end
|
||||
end
|
||||
|
||||
function public.test2()
|
||||
local data = private.load_data()
|
||||
for key, _ in data do
|
||||
data[key] = data[key]..'5000@5000'
|
||||
for i=1,100 do
|
||||
data[key] = data[key]..';9999@9995'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function private.read_record(item_key)
|
||||
local data = private.load_data()
|
||||
|
||||
@@ -64,6 +47,7 @@ function private.read_record(item_key)
|
||||
end
|
||||
|
||||
function private.write_record(item_key, record)
|
||||
private.value_cache[item_key] = nil
|
||||
local data = private.load_data()
|
||||
data[item_key] = Aux.util.join({
|
||||
record.next_push or '',
|
||||
@@ -96,20 +80,24 @@ function public.price_data(item_key)
|
||||
end
|
||||
|
||||
function public.value(item_key)
|
||||
local item_record = private.read_record(item_key)
|
||||
if not private.value_cache[item_key] then
|
||||
local item_record = private.read_record(item_key)
|
||||
|
||||
local i = 1
|
||||
local median_list = {}
|
||||
while getn(median_list) <= 11 and i <= getn(item_record.data_points) do
|
||||
tinsert(median_list, item_record.data_points[i].market_value)
|
||||
i = i + 1
|
||||
local i = 1
|
||||
local median_list = {}
|
||||
while getn(median_list) <= 11 and i <= getn(item_record.data_points) do
|
||||
tinsert(median_list, item_record.data_points[i].market_value)
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
if getn(median_list) > 0 then
|
||||
private.value_cache[item_key] = private.median(median_list)
|
||||
else
|
||||
private.value_cache[item_key] = private.market_value(item_record)
|
||||
end
|
||||
end
|
||||
|
||||
if getn(median_list) > 0 then
|
||||
return private.median(median_list)
|
||||
else
|
||||
return private.market_value(item_record)
|
||||
end
|
||||
return private.value_cache[item_key]
|
||||
end
|
||||
|
||||
function public.market_value(item_key)
|
||||
@@ -140,8 +128,8 @@ function private.push_record(item_record)
|
||||
|
||||
local market_value = private.market_value(item_record)
|
||||
if market_value then
|
||||
tinsert(item_record.data_points, 1, { market_value = market_value, time = time() })
|
||||
while getn(item_record.data_points) > 100 do
|
||||
tinsert(item_record.data_points, 1, { market_value = market_value, time = item_record.next_push })
|
||||
while getn(item_record.data_points) > 31 do
|
||||
tremove(item_record.data_points)
|
||||
end
|
||||
end
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
local private, public = {}, {}
|
||||
Aux.persistence = public
|
||||
|
||||
aux_database = {}
|
||||
aux_datasets = {}
|
||||
|
||||
function public.on_load()
|
||||
Aux.control.as_soon_as(function() private.faction = UnitFactionGroup('player') return private.faction end, Aux.util.pass)
|
||||
@@ -14,8 +14,8 @@ end
|
||||
|
||||
function public.load_dataset()
|
||||
local dataset_key = private.get_dataset_key()
|
||||
aux_database[dataset_key] = aux_database[dataset_key] or {}
|
||||
return aux_database[dataset_key]
|
||||
aux_datasets[dataset_key] = aux_datasets[dataset_key] or {}
|
||||
return aux_datasets[dataset_key]
|
||||
end
|
||||
|
||||
function public.serialize(data, separator, compactor)
|
||||
|
||||
+57
-16
@@ -11,19 +11,53 @@ local BUYOUT_MODE, BID_MODE, FULL_MODE = 1, 2, 3
|
||||
|
||||
aux_post_mode = FULL_MODE
|
||||
|
||||
function private.load_settings(item_record)
|
||||
local item_record = item_record or selected_item
|
||||
local dataset = Aux.persistence.load_dataset()
|
||||
dataset.post = dataset.post or {}
|
||||
dataset.post[item_record.key] = dataset.post[item_record.key] or {
|
||||
function private.default_settings()
|
||||
return {
|
||||
duration = DURATION_8,
|
||||
stack_size = 1,
|
||||
start_price = 0,
|
||||
buyout_price = 0,
|
||||
post_all = true,
|
||||
hidden = false,
|
||||
post_all = 1,
|
||||
hidden = nil,
|
||||
}
|
||||
return dataset.post[item_record.key]
|
||||
end
|
||||
|
||||
function private.read_settings(item_key)
|
||||
item_key = item_key or selected_item.key
|
||||
local dataset = Aux.persistence.load_dataset()
|
||||
dataset.post = dataset.post or {}
|
||||
|
||||
local settings
|
||||
if dataset.post[item_key] then
|
||||
local fields = Aux.util.split(dataset.post[item_key], '#')
|
||||
settings = {
|
||||
stack_size = tonumber(fields[1]),
|
||||
duration = tonumber(fields[2]),
|
||||
start_price = tonumber(fields[3]),
|
||||
buyout_price = tonumber(fields[4]),
|
||||
post_all = tonumber(fields[5]),
|
||||
hidden = tonumber(fields[6]),
|
||||
}
|
||||
else
|
||||
settings = private.default_settings()
|
||||
end
|
||||
return settings
|
||||
end
|
||||
|
||||
function private.write_settings(settings, item_key)
|
||||
item_key = item_key or selected_item.key
|
||||
|
||||
local dataset = Aux.persistence.load_dataset()
|
||||
dataset.post = dataset.post or {}
|
||||
|
||||
dataset.post[item_key] = Aux.util.join({
|
||||
settings.stack_size,
|
||||
settings.duration,
|
||||
settings.start_price,
|
||||
settings.buyout_price,
|
||||
tostring(settings.post_all),
|
||||
tostring(settings.hidden),
|
||||
}, '#')
|
||||
end
|
||||
|
||||
function private.get_unit_start_price()
|
||||
@@ -60,7 +94,7 @@ function private.update_inventory_listing()
|
||||
end
|
||||
|
||||
Aux.item_listing.populate(private.item_listing, Aux.util.filter(inventory_records, function(record)
|
||||
local settings = private.load_settings(record)
|
||||
local settings = private.read_settings(record.key)
|
||||
return record.aux_quantity > 0 and (not settings.hidden or private.show_hidden_checkbox:GetChecked())
|
||||
end))
|
||||
end
|
||||
@@ -246,8 +280,9 @@ function public.on_load()
|
||||
slider:SetValue(this:GetNumber())
|
||||
private.quantity_update()
|
||||
if selected_item then
|
||||
local settings = private.load_settings()
|
||||
local settings = private.read_settings()
|
||||
settings.stack_size = this:GetNumber()
|
||||
private.write_settings(settings)
|
||||
end
|
||||
end)
|
||||
slider.editbox:SetScript('OnEscapePressed', function()
|
||||
@@ -281,8 +316,9 @@ function public.on_load()
|
||||
checkbox:SetHeight(22)
|
||||
checkbox:SetPoint('TOPLEFT', private.stack_size_slider, 'BOTTOMLEFT', -3, -7)
|
||||
checkbox:SetScript('OnClick', function()
|
||||
local settings = private.load_settings()
|
||||
local settings = private.read_settings()
|
||||
settings.post_all = this:GetChecked()
|
||||
private.write_settings(settings)
|
||||
private.update_recommendation()
|
||||
refresh = true
|
||||
end)
|
||||
@@ -348,8 +384,9 @@ function public.on_load()
|
||||
checkbox:SetHeight(22)
|
||||
checkbox:SetPoint('TOPRIGHT', -85, -6)
|
||||
checkbox:SetScript('OnClick', function()
|
||||
local settings = private.load_settings()
|
||||
local settings = private.read_settings()
|
||||
settings.hidden = this:GetChecked()
|
||||
private.write_settings(settings)
|
||||
refresh = true
|
||||
end)
|
||||
local label = Aux.gui.label(checkbox, 13)
|
||||
@@ -387,10 +424,11 @@ function public.on_load()
|
||||
editbox:SetWidth(150)
|
||||
editbox:SetScript('OnTextChanged', function()
|
||||
if selected_item then
|
||||
local settings = private.load_settings()
|
||||
local settings = private.read_settings()
|
||||
settings.start_price = Aux.money.from_string(this:GetText())
|
||||
local historical_value = Aux.history.value(selected_item.key)
|
||||
private.start_price_percentage:SetText(historical_value and Aux.auction_listing.percentage_historical(Aux.round(settings.start_price / historical_value * 100)) or '---')
|
||||
private.write_settings(settings)
|
||||
end
|
||||
refresh = true
|
||||
end)
|
||||
@@ -435,10 +473,11 @@ function public.on_load()
|
||||
editbox:SetWidth(150)
|
||||
editbox:SetScript('OnTextChanged', function()
|
||||
if selected_item then
|
||||
local settings = private.load_settings()
|
||||
local settings = private.read_settings()
|
||||
settings.buyout_price = Aux.money.from_string(this:GetText())
|
||||
local historical_value = Aux.history.value(selected_item.key)
|
||||
private.buyout_price_percentage:SetText(historical_value and Aux.auction_listing.percentage_historical(Aux.round(settings.buyout_price / historical_value * 100)) or '---')
|
||||
private.write_settings(settings)
|
||||
end
|
||||
refresh = true
|
||||
end)
|
||||
@@ -761,7 +800,7 @@ function private.unit_vendor_price(item_key)
|
||||
end
|
||||
|
||||
function private.set_item(item)
|
||||
local settings = private.load_settings(item)
|
||||
local settings = private.read_settings(item.key)
|
||||
|
||||
item.unit_vendor_price = private.unit_vendor_price(item.key)
|
||||
if not item.unit_vendor_price then
|
||||
@@ -800,6 +839,7 @@ function private.set_item(item)
|
||||
private.refresh_entries()
|
||||
end
|
||||
|
||||
private.write_settings(settings, item.key)
|
||||
private.update_recommendation()
|
||||
refresh = true
|
||||
end
|
||||
@@ -960,8 +1000,9 @@ function private.initialize_duration_dropdown()
|
||||
|
||||
local function on_click()
|
||||
UIDropDownMenu_SetSelectedValue(private.duration_dropdown, this.value)
|
||||
local settings = private.load_settings()
|
||||
local settings = private.read_settings()
|
||||
settings.duration = this.value
|
||||
private.write_settings(settings)
|
||||
private.update_recommendation()
|
||||
end
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ function SlashCmdList.AUX(parameter)
|
||||
Aux.persistence.load_dataset().post = nil
|
||||
Aux.log('Post settings cleared.')
|
||||
elseif parameter == 'clear' then
|
||||
aux_database = {}
|
||||
aux_datasets = {}
|
||||
Aux.log('Database cleared.')
|
||||
elseif parameter == 'generate item cache' then
|
||||
Aux.static.generate_cache()
|
||||
|
||||
Reference in New Issue
Block a user