Do not try to fetch price for items which contain no market group according to CCP data
This commit is contained in:
@@ -239,7 +239,7 @@ class Item(EqBase):
|
||||
self.__offensive = None
|
||||
self.__assistive = None
|
||||
self.__overrides = None
|
||||
self.__price = None
|
||||
self.__priceObj = None
|
||||
|
||||
@property
|
||||
def attributes(self):
|
||||
@@ -446,27 +446,37 @@ class Item(EqBase):
|
||||
|
||||
@property
|
||||
def price(self):
|
||||
priceObj = self.priceObj
|
||||
if not priceObj:
|
||||
return 0
|
||||
else:
|
||||
return priceObj.price
|
||||
|
||||
@property
|
||||
def priceObj(self):
|
||||
if not self.marketGroupID:
|
||||
return None
|
||||
|
||||
# todo: use `from sqlalchemy import inspect` instead (mac-deprecated doesn't have inspect(), was imp[lemented in 0.8)
|
||||
if self.__price is not None and getattr(self.__price, '_sa_instance_state', None) and self.__price._sa_instance_state.deleted:
|
||||
if self.__priceObj is not None and getattr(self.__priceObj, '_sa_instance_state', None) and self.__priceObj._sa_instance_state.deleted:
|
||||
pyfalog.debug("Price data for {} was deleted (probably from a cache reset), resetting object".format(self.ID))
|
||||
self.__price = None
|
||||
self.__priceObj = None
|
||||
|
||||
if self.__price is None:
|
||||
if self.__priceObj is None:
|
||||
db_price = eos.db.getPrice(self.ID)
|
||||
# do not yet have a price in the database for this item, create one
|
||||
if db_price is None:
|
||||
pyfalog.debug("Creating a price for {}".format(self.ID))
|
||||
self.__price = types_Price(self.ID)
|
||||
eos.db.add(self.__price)
|
||||
self.__priceObj = types_Price(self.ID)
|
||||
eos.db.add(self.__priceObj)
|
||||
# Commented out by DarkPhoenix: it caused issues when opening stats for item with many
|
||||
# variations, as each commit takes ~50 ms, for items with 30 variations time to open stats
|
||||
# window could reach 2 seconds. Hopefully just adding it is sufficient.
|
||||
# eos.db.commit()
|
||||
else:
|
||||
self.__price = db_price
|
||||
self.__priceObj = db_price
|
||||
|
||||
return self.__price
|
||||
return self.__priceObj
|
||||
|
||||
@property
|
||||
def isAbyssal(self):
|
||||
|
||||
Reference in New Issue
Block a user