Exemplo n.º 1
0
def get_componentized_values(eve_types, options=None):
    componentized_items = {}
    for eve_type in eve_types:
        type_details = get_type_by_id(eve_type)
        if type_details and 'components' in type_details:
            component_types = dict((c['materialTypeID'], c['quantity'])
                                   for c in type_details['components'])

            component_prices = get_market_prices(component_types.keys(),
                                                 options=options)
            price_map = dict(component_prices)
            zeroed_price = {'avg': 0, 'min': 0, 'max': 0, 'price': 0}
            complete_price_data = {
                'buy': zeroed_price.copy(),
                'sell': zeroed_price.copy(),
                'all': zeroed_price.copy(),
            }
            for component, quantity in component_types.items():
                for market_type in ['buy', 'sell', 'all']:
                    for stat in ['avg', 'min', 'max', 'price']:
                        _price = price_map.get(component)
                        if _price:
                            complete_price_data[market_type][stat] += (
                                _price[market_type][stat] * quantity)
            componentized_items[eve_type] = complete_price_data
            # Cache for up to 10 hours
            cache.set(
                memcache_type_key(eve_type, options=options),
                complete_price_data,
                timeout=10 * 60 * 60)

    return componentized_items
Exemplo n.º 2
0
def get_componentized_values(eve_types, options=None):
    componentized_items = {}
    for eve_type in eve_types:
        type_details = get_type_by_id(eve_type)
        if type_details and 'components' in type_details:
            component_types = dict((c['materialTypeID'], c['quantity'])
                                   for c in type_details['components'])

            component_prices = get_market_prices(component_types.keys(),
                                                 options=options)
            price_map = dict(component_prices)
            zeroed_price = {'avg': 0, 'min': 0, 'max': 0, 'price': 0}
            complete_price_data = {
                'buy': zeroed_price.copy(),
                'sell': zeroed_price.copy(),
                'all': zeroed_price.copy(),
            }
            for component, quantity in component_types.items():
                for market_type in ['buy', 'sell', 'all']:
                    for stat in ['avg', 'min', 'max', 'price']:
                        _price = price_map.get(component)
                        if _price:
                            complete_price_data[market_type][stat] += (
                                _price[market_type][stat] * quantity)
            componentized_items[eve_type] = complete_price_data
            # Cache for up to 10 hours
            cache.set(memcache_type_key(eve_type, options=options),
                      complete_price_data,
                      timeout=10 * 60 * 60)

    return componentized_items
Exemplo n.º 3
0
def get_invalid_values(eve_types, options=None):
    invalid_items = {}
    for eve_type in eve_types:
        type_details = get_type_by_id(eve_type)
        if type_details and type_details.get('market') is False:
            zeroed_price = {'avg': 0, 'min': 0, 'max': 0, 'price': 0}
            price_info = {
                'buy': zeroed_price.copy(),
                'sell': zeroed_price.copy(),
                'all': zeroed_price.copy(),
            }
            invalid_items[eve_type] = price_info
    return invalid_items
Exemplo n.º 4
0
def get_invalid_values(eve_types, options=None):
    invalid_items = {}
    for eve_type in eve_types:
        type_details = get_type_by_id(eve_type)
        if type_details and type_details.get('market') is False:
            zeroed_price = {'avg': 0, 'min': 0, 'max': 0, 'price': 0}
            price_info = {
                'buy': zeroed_price.copy(),
                'sell': zeroed_price.copy(),
                'all': zeroed_price.copy(),
            }
            invalid_items[eve_type] = price_info
    return invalid_items