Optimize price fetching columns a bit, only use delayed showing if we

can't get the price right away.
This commit is contained in:
cncfanatics
2010-10-28 07:32:10 +02:00
parent 8b5640d9df
commit 59face543a
3 changed files with 24 additions and 12 deletions

2
eos

Submodule eos updated: a57531436a...3cd4768c9c

View File

@@ -34,7 +34,12 @@ class ModulePrice(ViewColumn):
def getText(self, mod):
return False if mod.item is not None else ""
if mod.item is None:
return ""
sMarket = service.Market.getInstance()
price = sMarket.getPriceNow(mod.item.ID).price
return formatAmount(price, 3, 3, 9) if price is not None else False
def delayedText(self, mod, display, colItem):
def callback(requests):

View File

@@ -247,19 +247,26 @@ class Market():
return list(l), populatedMetas
def getPriceNow(self, typeID):
price = self.priceCache.get(typeID)
if price is None:
try:
price = eos.db.getPrice(typeID)
except NoResultFound:
price = eos.types.Price(typeID)
eos.db.saveddata_session.add(price)
self.priceCache[typeID] = price
return price
def getPricesNow(self, typeIDs):
return map(self.getPrice, typeIDs)
def getPrices(self, typeIDs, callback):
requests = []
for typeID in typeIDs:
price = self.priceCache.get(typeID)
if price is None:
try:
price = eos.db.getPrice(typeID)
except NoResultFound:
price = eos.types.Price(typeID)
eos.db.saveddata_session.add(price)
self.priceCache[typeID] = price
price = self.getPriceNow(typeID)
requests.append(price)
def cb():