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

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():