Ejemplo n.º 1
0
def cache_item_stats(self, session=None):
    if session is None:
        session = self.session()
    api = RLGarageAPI()
    items = api.get_item_list(0, 10000, override=True)['items']
    category_map = {
        'car': 1,
        'wheels': 2,
        'boost': 3,
        'topper': 4,
        'antenna': 5,
        'skin': 6,
        'trail': 9,
        'goal_explosion': 10,
        'banner': 11,
        'engine_audio': 12,
    }
    ItemStatsWrapper.create_unpainted_stats(session=session, override=True)
    ItemStatsWrapper.create_unpainted_stats(session=session, counts=True, override=True)
    for value in category_map.values():
        ItemStatsWrapper.create_unpainted_stats(value, session=session, override=True)
    for key in category_map:
        ItemStatsWrapper.get_most_used_by_column(key, session=session, override=True)
    for item in items:
        id_ = item['ingameid']
        if id_ is None:
            continue
        print("Item", item)
        try:
            ItemStatsWrapper.get_item_usage_over_time(id_, session=session, override=True)
        except:
            print("Error")
Ejemplo n.º 2
0
def calc_item_stats(self, session=None):
    if session is None:
        sess = self.session()
    else:
        sess = session
    results = ItemStatsWrapper.create_stats(sess)
    if lazy_get_redis() is not None:
        lazy_get_redis().set('item_stats', json.dumps(results))
Ejemplo n.º 3
0
def api_get_item_usage(query_params=None):
    return better_jsonify(
        ItemStatsWrapper.get_item_usage_over_time(query_params['id']))
Ejemplo n.º 4
0
def api_get_item_order(query_params):
    stats = ItemStatsWrapper.create_unpainted_stats(counts=True)
    if query_params['category'] is not None:
        stats = stats[str(query_params['category'])]
    return better_jsonify(stats)
Ejemplo n.º 5
0
def api_get_items_list(query_params=None):
    if 'category' in query_params:
        return better_jsonify(ItemStatsWrapper.create_item_list(query_params))
    api = RLGarageAPI()
    return better_jsonify(
        api.get_item_list(query_params['page'], query_params['limit']))