Optimize price fetching columns a bit, only use delayed showing if we
can't get the price right away.
This commit is contained in:
2
eos
2
eos
Submodule eos updated: a57531436a...3cd4768c9c
@@ -34,7 +34,12 @@ class ModulePrice(ViewColumn):
|
|||||||
|
|
||||||
|
|
||||||
def getText(self, mod):
|
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 delayedText(self, mod, display, colItem):
|
||||||
def callback(requests):
|
def callback(requests):
|
||||||
|
|||||||
@@ -247,19 +247,26 @@ class Market():
|
|||||||
|
|
||||||
return list(l), populatedMetas
|
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):
|
def getPrices(self, typeIDs, callback):
|
||||||
requests = []
|
requests = []
|
||||||
for typeID in typeIDs:
|
for typeID in typeIDs:
|
||||||
price = self.priceCache.get(typeID)
|
price = self.getPriceNow(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
|
|
||||||
|
|
||||||
requests.append(price)
|
requests.append(price)
|
||||||
|
|
||||||
def cb():
|
def cb():
|
||||||
|
|||||||
Reference in New Issue
Block a user