コード例 #1
0
def get_table(search_date, channel_id=-1, cur_server=-1):

    # new_log_lst = daily_log_dat.get_new_log_lst(search_date, search_date)
    #获取全部新手引导日志
    all_newbie_log_lst = dat_log_util.read_file(game_define.EVENT_ACTION_FINISH_NEWBIE, search_date, search_date, cur_server)
    # print all_newbie_log_lst
    if channel_id >= 0:
        all_newbie_log_lst = daily_log_dat.filter_logs(all_newbie_log_lst, function=lambda x: x['platform_id'] == channel_id)
    if cur_server >= 0:
        all_newbie_log_lst = daily_log_dat.filter_logs(all_newbie_log_lst, function=lambda x: x['server_id'] == cur_server)
    # 总共5个引导步骤 (1-6)
    total_user = daily_log_dat.get_set_num_with_key(all_newbie_log_lst, 'uid')
    complete_user_dict = dict()
    newbie_name = [u'第一场战斗', u'抽取宝贝球', u'加入队伍', u'自动战斗', u'每日任务']

    for i in xrange(1, 6):
        # 当前引导的所有日志
        guide_index_log_lst = daily_log_dat.filter_logs(all_newbie_log_lst, function=lambda x: x['newbie_id'] == i)
        complete_user_num = daily_log_dat.get_set_num_with_key(guide_index_log_lst, 'uid')
        complete_user_dict[i] = complete_user_num

    table_result = []
    for i in xrange(1, 6):
        next_num = complete_user_dict.get(i+1,0)
        row = [
            i,
            newbie_name[i-1],
            complete_user_dict[i], # 完成人数
        ]
        table_result.append(row)

    return table_result
コード例 #2
0
def get_table(search_date, channel_id=-1, cur_server=-1):

    # new_log_lst = daily_log_dat.get_new_log_lst(search_date, search_date)
    # #获取全部新手引导日志
    # all_guide_log_lst = daily_log_dat.filter_logs(new_log_lst, action=game_define.EVENT_ACTION_FINISH_GUIDE)
    all_guide_log_lst = dat_log_util.read_file(
        game_define.EVENT_ACTION_FINISH_GUIDE, search_date, search_date,
        cur_server)
    # print all_guide_log_lst
    if channel_id >= 0:
        all_guide_log_lst = daily_log_dat.filter_logs(
            all_guide_log_lst,
            function=lambda x: x['platform_id'] == channel_id)
    if cur_server >= 0:
        all_guide_log_lst = daily_log_dat.filter_logs(
            all_guide_log_lst, function=lambda x: x['server_id'] == cur_server)

    # 总共5个引导步骤 (1-6)
    total_user = daily_log_dat.get_set_num_with_key(all_guide_log_lst, 'uid')
    complete_user_dict = dict()
    guide_name = [
        u'宠物升级突破_4级开启', u'宠物升星_17级开启', u'宠物进化_10级开启', u'宠物技能升级_13级开启',
        u'宠物洗练_30级开启', u'宠物装备强化_23级开启', u'新队伍位置_6级开启'
    ]

    # 引导步骤按解锁等级排序
    unlock_order = [1, 7, 6, 3, 4, 2, 5]
    for i in xrange(1, 8):
        # 当前引导的所有日志
        guide_index_log_lst = daily_log_dat.filter_logs(
            all_guide_log_lst, function=lambda x: x['guide_id'] == i)
        complete_user_num = daily_log_dat.get_set_num_with_key(
            guide_index_log_lst, 'uid')
        complete_user_dict[i] = complete_user_num

    table_result = []
    for i in unlock_order:
        next_num = complete_user_dict.get(i + 1, 0)
        row = [
            search_date.strftime('%Y-%m-%d'),
            i,
            guide_name[i - 1],
            complete_user_dict[i],  # 完成人数
        ]
        table_result.append(row)

    return table_result
コード例 #3
0
def get_table(search_date, channel_id=-1, cur_server=-1):

    # new_log_lst = daily_log_dat.get_new_log_lst(search_date, search_date)
    # #获取全部新手引导日志
    # all_guide_log_lst = daily_log_dat.filter_logs(new_log_lst, action=game_define.EVENT_ACTION_FINISH_GUIDE)
    all_guide_log_lst = dat_log_util.read_file(game_define.EVENT_ACTION_FINISH_GUIDE, search_date, search_date, cur_server)
    # print all_guide_log_lst
    if channel_id >= 0:
        all_guide_log_lst = daily_log_dat.filter_logs(all_guide_log_lst, function=lambda x: x['platform_id'] == channel_id)
    if cur_server >= 0:
        all_guide_log_lst = daily_log_dat.filter_logs(all_guide_log_lst, function=lambda x: x['server_id'] == cur_server)

    # 总共5个引导步骤 (1-6)
    total_user = daily_log_dat.get_set_num_with_key(all_guide_log_lst, 'uid')
    complete_user_dict = dict()
    guide_name = [u'宠物升级突破_4级开启', u'宠物升星_17级开启', u'宠物进化_10级开启', u'宠物技能升级_13级开启', u'宠物洗练_30级开启', u'宠物装备强化_23级开启', u'新队伍位置_6级开启']

    # 引导步骤按解锁等级排序
    unlock_order = [1, 7, 6, 3, 4, 2, 5]
    for i in xrange(1, 8):
        # 当前引导的所有日志
        guide_index_log_lst = daily_log_dat.filter_logs(all_guide_log_lst, function=lambda x: x['guide_id'] == i)
        complete_user_num = daily_log_dat.get_set_num_with_key(guide_index_log_lst, 'uid')
        complete_user_dict[i] = complete_user_num

    table_result = []
    for i in unlock_order:
        next_num = complete_user_dict.get(i+1,0)
        row = [
            search_date.strftime('%Y-%m-%d'),
            i,
            guide_name[i-1],
            complete_user_dict[i],  # 完成人数
        ]
        table_result.append(row)

    return table_result
コード例 #4
0
def get_table(search_start_date,
              search_end_date,
              register_start_date=None,
              register_end_date=None,
              server_id=-1):
    """
        获取展示表格
        register_start_date 注册开始时间
        register_end_date 注册结束时间
        search_start_date 查询开始时间
        search_end_date 查询结束时间
    """
    all_stone_shop_log_lst = dat_log_util.read_file(
        game_define.EVENT_ACTION_STONE_SHOP_BUY, search_start_date,
        search_end_date, server_id)
    # if channel_id >= 0:
    #     all_stone_shop_log_lst = daily_log_dat.filter_logs(all_stone_shop_log_lst, function=lambda x: x['platform_id'] == channel_id)
    # if server_id >= 0:
    #     all_stone_shop_log_lst = daily_log_dat.filter_logs(all_stone_shop_log_lst, function=lambda x: x['server_id'] == server_id)

    #获取符合条件的日志
    if register_start_date and register_end_date:
        all_stone_shop_log_lst = daily_log_dat.filter_logs(
            all_stone_shop_log_lst,
            function=lambda log: register_start_date <= log[
                'install'] <= register_end_date)
    # print all_stone_shop_log_lst
    # 全部钻石商城物品购买日志
    # print("all_stone_shop_log_lst: "+str(all_stone_shop_log_lst))
    # 获取所有钻石商城物品玩家设备
    # device_lst = daily_log_dat.get_set_with_key(all_stone_shop_log_lst, 'dev_id')

    # 获取所有钻石商城物品购买日志玩家UID
    all_uid_lst = daily_log_dat.get_set_with_key(all_stone_shop_log_lst, 'uid')

    # 消耗钻石总数
    total_cost_stone = daily_log_dat.get_sum_int_with_key(
        all_stone_shop_log_lst, 'cost_stone')

    # 根据ID拆分日志
    item_logs_dict = dict()
    for _log in all_stone_shop_log_lst:
        _item_info = _log['add_item_list']
        _item_tid = _item_info[0]

        if _item_tid in item_logs_dict:
            item_logs_dict[_item_tid].append(_log)
        else:
            lst = [_log]
            item_logs_dict[_item_tid] = lst

    table_lst = []
    for _item_tid, _log in item_logs_dict.items():

        user_num = daily_log_dat.get_set_num_with_key(_log, 'uid')
        # 购买物品
        item_config = game_config.get_item_config(int(_item_tid))

        event_log_act = item_config['name']
        # 钻石数
        cost_stone = daily_log_dat.get_sum_int_with_key(_log, 'cost_stone')
        # 次数
        cost_num = len(_log)
        # 参与率
        take_part_rate = _get_rate(user_num, len(all_uid_lst))
        # 钻石比率
        first_cost_stone_rate = _get_rate(cost_stone, total_cost_stone)
        # 人数比率
        # cur_user_num_rate = _get_rate(user_num, len(all_uid_lst))

        row = [
            event_log_act, cost_stone, user_num, cost_num,
            str(take_part_rate * 100) + "%",
            str(first_cost_stone_rate * 100) + "%"
        ]
        table_lst.append(row)

    return table_lst