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):
|
||||
|
||||
@@ -133,7 +133,7 @@ class ItemCompare(wx.Panel):
|
||||
except IndexError:
|
||||
# Price
|
||||
if sort == len(self.attrs) + 1:
|
||||
func = lambda i: i.price.price if i.price.price != 0 else float("Inf")
|
||||
func = lambda i: i.price if i.price != 0 else float("Inf")
|
||||
# Something else
|
||||
else:
|
||||
self.sortReverse = False
|
||||
@@ -168,7 +168,7 @@ class ItemCompare(wx.Panel):
|
||||
self.paramList.SetItem(i, x + 1, valueUnit)
|
||||
|
||||
# Add prices
|
||||
self.paramList.SetItem(i, len(self.attrs) + 1, formatAmount(item.price.price, 3, 3, 9, currency=True))
|
||||
self.paramList.SetItem(i, len(self.attrs) + 1, formatAmount(item.price, 3, 3, 9, currency=True) if item.price else "")
|
||||
|
||||
self.paramList.RefreshRows()
|
||||
self.Layout()
|
||||
|
||||
@@ -100,32 +100,32 @@ class PriceViewFull(StatsView):
|
||||
implant_price = 0
|
||||
|
||||
if fit:
|
||||
ship_price = fit.ship.item.price.price
|
||||
ship_price = fit.ship.item.price
|
||||
|
||||
if fit.modules:
|
||||
for module in fit.modules:
|
||||
if not module.isEmpty:
|
||||
module_price += module.item.price.price
|
||||
module_price += module.item.price
|
||||
|
||||
if fit.drones:
|
||||
for drone in fit.drones:
|
||||
drone_price += drone.item.price.price * drone.amount
|
||||
drone_price += drone.item.price * drone.amount
|
||||
|
||||
if fit.fighters:
|
||||
for fighter in fit.fighters:
|
||||
fighter_price += fighter.item.price.price * fighter.amountActive
|
||||
fighter_price += fighter.item.price * fighter.amountActive
|
||||
|
||||
if fit.cargo:
|
||||
for cargo in fit.cargo:
|
||||
cargo_price += cargo.item.price.price * cargo.amount
|
||||
cargo_price += cargo.item.price * cargo.amount
|
||||
|
||||
if fit.boosters:
|
||||
for booster in fit.boosters:
|
||||
booster_price += booster.item.price.price
|
||||
booster_price += booster.item.price
|
||||
|
||||
if fit.implants:
|
||||
for implant in fit.implants:
|
||||
implant_price += implant.item.price.price
|
||||
implant_price += implant.item.price
|
||||
|
||||
total_price = 0
|
||||
|
||||
|
||||
@@ -94,32 +94,32 @@ class PriceViewMinimal(StatsView):
|
||||
implant_price = 0
|
||||
|
||||
if fit:
|
||||
ship_price = fit.ship.item.price.price
|
||||
ship_price = fit.ship.item.price
|
||||
|
||||
if fit.modules:
|
||||
for module in fit.modules:
|
||||
if not module.isEmpty:
|
||||
module_price += module.item.price.price
|
||||
module_price += module.item.price
|
||||
|
||||
if fit.drones:
|
||||
for drone in fit.drones:
|
||||
drone_price += drone.item.price.price * drone.amount
|
||||
drone_price += drone.item.price * drone.amount
|
||||
|
||||
if fit.fighters:
|
||||
for fighter in fit.fighters:
|
||||
fighter_price += fighter.item.price.price * fighter.amountActive
|
||||
fighter_price += fighter.item.price * fighter.amountActive
|
||||
|
||||
if fit.cargo:
|
||||
for cargo in fit.cargo:
|
||||
cargo_price += cargo.item.price.price * cargo.amount
|
||||
cargo_price += cargo.item.price * cargo.amount
|
||||
|
||||
if fit.boosters:
|
||||
for booster in fit.boosters:
|
||||
booster_price += booster.item.price.price
|
||||
booster_price += booster.item.price
|
||||
|
||||
if fit.implants:
|
||||
for implant in fit.implants:
|
||||
implant_price += implant.item.price.price
|
||||
implant_price += implant.item.price
|
||||
|
||||
fitting_price = module_price
|
||||
|
||||
|
||||
@@ -45,13 +45,19 @@ class Price(ViewColumn):
|
||||
if stuff.isEmpty:
|
||||
return ""
|
||||
|
||||
price = stuff.item.price
|
||||
priceObj = stuff.item.priceObj
|
||||
|
||||
if not price or not price.isValid:
|
||||
if not priceObj:
|
||||
return ""
|
||||
|
||||
if not priceObj.isValid:
|
||||
return False
|
||||
|
||||
# Fetch actual price as float to not modify its value on Price object
|
||||
price = price.price
|
||||
price = priceObj.price
|
||||
|
||||
if price == 0:
|
||||
return ""
|
||||
|
||||
if isinstance(stuff, Drone) or isinstance(stuff, Cargo):
|
||||
price *= stuff.amount
|
||||
|
||||
@@ -28,7 +28,7 @@ from service.price import Price, VALIDITY
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
|
||||
class EveCentral(object):
|
||||
class EveMarketer(object):
|
||||
|
||||
name = "evemarketer"
|
||||
|
||||
@@ -67,4 +67,4 @@ class EveCentral(object):
|
||||
del priceMap[typeID]
|
||||
|
||||
|
||||
Price.register(EveCentral)
|
||||
Price.register(EveMarketer)
|
||||
|
||||
@@ -167,15 +167,16 @@ class Price(object):
|
||||
sMkt = Market.getInstance()
|
||||
item = sMkt.getItem(objitem)
|
||||
|
||||
return item.price.price
|
||||
return item.price
|
||||
|
||||
def getPrices(self, objitems, callback, waitforthread=False):
|
||||
"""Get prices for multiple typeIDs"""
|
||||
requests = []
|
||||
sMkt = Market.getInstance()
|
||||
for objitem in objitems:
|
||||
item = sMkt.getItem(objitem)
|
||||
requests.append(item.price)
|
||||
priceobj = sMkt.getItem(objitem).priceObj
|
||||
if priceobj:
|
||||
requests.append(priceobj)
|
||||
|
||||
def cb():
|
||||
try:
|
||||
@@ -197,6 +198,7 @@ class Price(object):
|
||||
|
||||
|
||||
class PriceWorkerThread(threading.Thread):
|
||||
|
||||
def __init__(self):
|
||||
threading.Thread.__init__(self)
|
||||
self.name = "PriceWorker"
|
||||
|
||||
Reference in New Issue
Block a user