Group market sources up to avoid cross-server price data confusion

This commit is contained in:
DarkPhoenix
2020-07-14 17:25:30 +03:00
parent df78eb5781
commit 63632e09b3
6 changed files with 16 additions and 6 deletions

View File

@@ -31,6 +31,7 @@ pyfalog = Logger(__name__)
class CEveMarketBase:
@staticmethod
def fetchPrices(priceMap, fetchTimeout, system=None, serenity=False):
params = {'typeid': {typeID for typeID in priceMap}}
@@ -52,10 +53,6 @@ class CEveMarketBase:
except (TypeError, ValueError):
pyfalog.warning('Failed to get price for: {0}', type_)
continue
# Price is 0 if evemarketer has info on this item, but it is not available
# for current scope limit. If we provided scope limit - make sure to skip
# such items to check globally, and do not skip if requested globally
if percprice == 0 and system is not None:
continue
priceMap[typeID].update(PriceStatus.fetchSuccess, percprice)
@@ -63,7 +60,9 @@ class CEveMarketBase:
class CEveMarketTq(CEveMarketBase):
name = 'www.ceve-market.org (Tranquility)' #let me at last
name = 'www.ceve-market.org (Tranquility)'
group = 'tranquility'
def __init__(self, priceMap, system, fetchTimeout):
# Try selected system first
@@ -72,8 +71,11 @@ class CEveMarketTq(CEveMarketBase):
if priceMap:
self.fetchPrices(priceMap, max(fetchTimeout / 3, 2), serenity=False)
class CEveMarketCn(CEveMarketBase):
name = 'www.ceve-market.org (Serenity)' #let me at last
name = 'www.ceve-market.org (Serenity)'
group = 'serenity'
def __init__(self, priceMap, system, fetchTimeout):
# Try selected system first
@@ -82,5 +84,6 @@ class CEveMarketCn(CEveMarketBase):
if priceMap:
self.fetchPrices(priceMap, max(fetchTimeout / 3, 2), serenity=True)
Price.register(CEveMarketCn)
Price.register(CEveMarketTq)

View File

@@ -32,6 +32,7 @@ pyfalog = Logger(__name__)
class EveMarketData:
name = 'eve-marketdata.com'
group = 'tranquility'
def __init__(self, priceMap, system, fetchTimeout):
# Try selected system first

View File

@@ -32,6 +32,7 @@ pyfalog = Logger(__name__)
class EveMarketer:
name = 'evemarketer'
group = 'tranquility'
def __init__(self, priceMap, system, fetchTimeout):
# Try selected system first

View File

@@ -38,6 +38,7 @@ systemAliases = {
class EvePraisal:
name = 'evepraisal'
group = 'tranquility'
def __init__(self, priceMap, system, fetchTimeout):
# Try selected system first

View File

@@ -39,6 +39,7 @@ locations = {
class FuzzworkMarket:
name = 'fuzzwork market'
group = 'tranquility'
def __init__(self, priceMap, system, fetchTimeout):
# Try selected system first

View File

@@ -106,6 +106,9 @@ class Price:
# attempt to find user's selected price source, otherwise get first one
sourceAll = list(cls.sources.keys())
sourcePrimary = sFit.serviceFittingOptions["priceSource"] if sFit.serviceFittingOptions["priceSource"] in sourceAll else sourceAll[0]
# When we have picked primary source, make sure to include only sources from the same group to avoid fetching
# tranquility data for serenity or vice versa
sourceAll = list(n for n, s in cls.sources.items() if s.group == cls.sources[sourcePrimary].group)
# Format: {source name: timeout weight}
sources = {sourcePrimary: len(sourceAll)}