From 89260d1d36bc3e32fc3ccc3681b8986951eded96 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Mon, 3 Jun 2019 18:29:38 +0300 Subject: [PATCH] Always prefer primary data source, and switch evepraisal market source to use min price for items --- service/marketSources/evepraisal.py | 9 +++++---- service/price.py | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/service/marketSources/evepraisal.py b/service/marketSources/evepraisal.py index b09299368..a8706de77 100644 --- a/service/marketSources/evepraisal.py +++ b/service/marketSources/evepraisal.py @@ -40,6 +40,7 @@ class EvePraisal: name = 'evepraisal' def __init__(self, priceMap, system, fetchTimeout): + print(priceMap) # Try selected system first self.fetchPrices(priceMap, max(2 * fetchTimeout / 3, 2), system) # If price was not available - try globally @@ -50,7 +51,7 @@ class EvePraisal: def fetchPrices(priceMap, fetchTimeout, system=None): jsonData = { 'market_name': systemAliases[system], - 'items': [{'type_id': typeID for typeID in priceMap}]} + 'items': [{'type_id': typeID} for typeID in priceMap]} baseurl = 'https://evepraisal.com/appraisal/structured.json' network = Network.getInstance() resp = network.post(baseurl, network.PRICES, jsonData=jsonData, timeout=fetchTimeout) @@ -63,13 +64,13 @@ class EvePraisal: for itemData in itemsData: try: typeID = int(itemData['typeID']) - percprice = itemData['prices']['sell']['percentile'] + price = itemData['prices']['sell']['min'] except (KeyError, TypeError): continue # evepraisal returns 0 if price data doesn't even exist for the item - if percprice == 0: + if price == 0: continue - priceMap[typeID].update(PriceStatus.fetchSuccess, percprice) + priceMap[typeID].update(PriceStatus.fetchSuccess, price) del priceMap[typeID] diff --git a/service/price.py b/service/price.py index 2b1d07ca5..ff6618d57 100644 --- a/service/price.py +++ b/service/price.py @@ -117,7 +117,8 @@ class Price: # Record timeouts as it will affect our final decision timedOutSources = {} - for source, timeoutWeight in sources.items(): + for source in sorted(sources, key=sources.get, reverse=True): + timeoutWeight = sources[source] pyfalog.info('Trying {}'.format(source)) timedOutSources[source] = False sourceFetchTimeout = timeoutWeight * timeoutWeightMult