added percentages of market value to tables

This commit is contained in:
Manuel Simon Hirsig
2016-01-18 20:43:43 +01:00
parent ba96d13d7c
commit 094c9d015d
5 changed files with 161 additions and 32 deletions
+58
View File
@@ -143,6 +143,34 @@ public.views = {
group_alpha_setter(cell, group)
end,
},
{
title = 'Pct',
width = 40,
comparator = function(group1, group2)
local market_price1 = Aux.history.get_market_value(group1[1].item_key)
local market_price2 = Aux.history.get_market_value(group2[1].item_key)
local factor1 = market_price1 and group1[1].buyout_price_per_unit / market_price1
local factor2 = market_price2 and group2[1].buyout_price_per_unit / market_price2
return Aux.util.compare(factor1, factor2, Aux.util.GT)
end,
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
cell_setter = function(cell, group)
local market_price = Aux.history.get_market_value(group[1].item_key)
local pct = market_price > 0 and ceil(100 / market_price * group[1].buyout_price_per_unit)
if not pct then
cell.text:SetText('N/A')
elseif pct > 999 then
cell.text:SetText('>999%')
else
cell.text:SetText(pct..'%')
end
if pct then
cell.text:SetTextColor(Aux.price_level_color(pct))
end
group_alpha_setter(cell, group)
end,
},
},
sort_order = {{column = 3, order = 'ascending' }},
},
@@ -394,6 +422,34 @@ public.views = {
auction_alpha_setter(cell, datum)
end,
},
{
title = 'Pct',
width = 40,
comparator = function(row1, row2)
local market_price1 = Aux.history.get_market_value(row1.item_key)
local market_price2 = Aux.history.get_market_value(row2.item_key)
local factor1 = market_price1 and row1.buyout_price_per_unit / market_price1
local factor2 = market_price2 and row2.buyout_price_per_unit / market_price2
return Aux.util.compare(factor1, factor2, Aux.util.GT)
end,
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
cell_setter = function(cell, datum)
local market_price = Aux.history.get_market_value(datum.item_key)
local pct = market_price > 0 and datum.buyout_price_per_unit and ceil(100 / market_price * datum.buyout_price_per_unit)
if not pct then
cell.text:SetText('N/A')
elseif pct > 999 then
cell.text:SetText('>999%')
else
cell.text:SetText(pct..'%')
end
if pct then
cell.text:SetTextColor(Aux.price_level_color(pct))
end
auction_alpha_setter(cell, datum)
end,
},
},
sort_order = {},
},
@@ -755,6 +811,8 @@ function create_auction_record(auction_info, current_page)
unique_id = auction_info.unique_id,
enchant_id = auction_info.enchant_id,
item_key = auction_info.item_key,
signature = Aux.auction_signature(auction_info.hyperlink, aux_quantity, bid, auction_info.buyout_price),
name = auction_info.name,