def make_file(split_date, server_id): new_log_lst = read_one_day_data( "USER_DETAIL", split_date, 'tables', server_id, ) user_num_dict = dict() lost_user_num_dict = dict() for dat in new_log_lst: for value in dat.values(): cur_lv = value['level'] if split_date == value['install']: user_num_dict[cur_lv] = user_num_dict.get(cur_lv, 0) + 1 next_split_date = split_date + datetime.timedelta(days=1) next_day_log_lst = read_one_day_data( "USER_DETAIL", next_split_date, 'tables', server_id, ) #这里再查第二天的new_log_lst for dat in next_day_log_lst: for value in dat.values(): cur_lv = value['level'] if split_date == value['install'] and value['last_play_time'].date( ) == value['install']: lost_user_num_dict[cur_lv] = lost_user_num_dict.get(cur_lv, 0) + 1 num_total = 0 for _table_lv in xrange(1, 121): num_total += user_num_dict.get(_table_lv, 0) # 遍历全部等级 table_row_lst = [] for _table_lv in xrange(1, 121): # 停留人数 user_num = user_num_dict.get(_table_lv, 0) # 流失人数 lost_num = lost_user_num_dict.get(int(_table_lv), 0) # 留存人数 stand_num = user_num - lost_num # 等级比率 level_rate = str(_get_rate(user_num, num_total) * 100) + "%" # 留存人数比率 level_lost_rate = str(_get_rate(stand_num, num_total) * 100) + "%" # 等级 停留人数 留存人数比率 等级流存率 content = [_table_lv, user_num, level_rate, level_lost_rate] table_row_lst.append(content) return table_row_lst
def make_action_file(search_date, server_id): table_lst = [] computle = set() all_uid_count = set() try: all_list = dat_log_util.read_one_day_data( 'EVENT_ACTION_ACTIVITY_TIME_LIMITED_SHIFT_SHOP', search_date, 'all_action', server_id)[0] except: print 'EVENT_ACTION_ACTIVITY_TIME_LIMITED_SHIFT_SHOP 不存在 或为空' try: rqui = dat_log_util.read_one_day_data('EVENT_ACTION_ROLE_LOGIN', search_date, 'all_action', server_id)[0] except: print 'EVENT_ACTION_ROLE_LOGIN 不存在 或为空' for _num in rqui: computle.add(_num['dev_id']) computle = len(computle) result_dict = dict() for _lst in all_list: # 循环 出物品名字 if len(_lst['add_item_list']): item_tid = game_config.get_item_config( int(_lst['add_item_list'][0]))['name'] user_uid = _lst['uid'] all_uid_count.add(_lst['uid']) if item_tid in result_dict: result_dict[item_tid]['item_num'] += 1 result_dict[item_tid]['user_set'].add(user_uid) else: result_dict[item_tid] = {'item_num': 1, 'user_set': {user_uid}} for _val in result_dict.values(): user_num = len(_val['user_set']) _val['user_num'] = user_num _val.pop('user_set') _val['ex_pre'] = str( round(float(_val['user_num']) / float(computle), 3)) + '%' _val['person_pre'] = str( round(float(_val['user_num']) / float(len(all_uid_count)))) + '%' for key in result_dict: table_lst.append([ key, result_dict[key]['item_num'], result_dict[key]['user_num'], result_dict[key]['ex_pre'], result_dict[key]['person_pre'], ]) return table_lst
def make_file(split_date, server_id): new_log_lst = read_one_day_data("USER_DETAIL", split_date, "tables", server_id) user_num_dict = dict() lost_user_num_dict = dict() for dat in new_log_lst: for value in dat.values(): cur_lv = value["level"] if split_date == value["install"]: user_num_dict[cur_lv] = user_num_dict.get(cur_lv, 0) + 1 next_split_date = split_date + datetime.timedelta(days=1) next_day_log_lst = read_one_day_data("USER_DETAIL", next_split_date, "tables", server_id) # 这里再查第二天的new_log_lst for dat in next_day_log_lst: for value in dat.values(): cur_lv = value["level"] if split_date == value["install"] and value["last_play_time"].date() == value["install"]: lost_user_num_dict[cur_lv] = lost_user_num_dict.get(cur_lv, 0) + 1 num_total = 0 for _table_lv in xrange(1, 121): num_total += user_num_dict.get(_table_lv, 0) # 遍历全部等级 table_row_lst = [] for _table_lv in xrange(1, 121): # 停留人数 user_num = user_num_dict.get(_table_lv, 0) # 流失人数 lost_num = lost_user_num_dict.get(int(_table_lv), 0) # 留存人数 stand_num = user_num - lost_num # 等级比率 level_rate = str(_get_rate(user_num, num_total) * 100) + "%" # 留存人数比率 level_lost_rate = str(_get_rate(stand_num, num_total) * 100) + "%" # 等级 停留人数 留存人数比率 等级流存率 content = [_table_lv, user_num, level_rate, level_lost_rate] table_row_lst.append(content) return table_row_lst
def make_action_file(search_date,server_id): global first, second, third, fourth,fifth,sixth,seventh # 取事件的文件 table_lst = [] seven_lv_data = dat_log_util.read_one_day_data('',search_date,'all_action',server_id) for _server_list in seven_lv_data: for _action_dict in _server_list: log_time = _action_dict['log_time'].strftime('%Y-%m-%d') if _action_dict['recharge_sum_id'] == 1 : first += 1 elif _action_dict['recharge_sum_id'] == 2 : second += 1 elif _action_dict['recharge_sum_id'] == 3 : third += 1 elif _action_dict['recharge_sum_id'] == 4 : fourth += 1 row = [log_time,first, second, third, fourth] table_lst.append(row) return table_lst
def make_action_file(search_date, server_id): global first, second, third, fourth, fifth, sixth, seventh # 取事件的文件 table_lst = [] seven_lv_data = dat_log_util.read_one_day_data('', search_date, 'all_action', server_id) for _server_list in seven_lv_data: for _action_dict in _server_list: log_time = _action_dict['log_time'].strftime('%Y-%m-%d') if _action_dict['recharge_sum_id'] == 1: first += 1 elif _action_dict['recharge_sum_id'] == 2: second += 1 elif _action_dict['recharge_sum_id'] == 3: third += 1 elif _action_dict['recharge_sum_id'] == 4: fourth += 1 row = [log_time, first, second, third, fourth] table_lst.append(row) return table_lst
def make_action_file(search_date,server_id): global first, second, third, fourth # 取事件的文件 row = [] table_lst = [] seven_lv_data = dat_log_util.read_one_day_data('EVENT_ACTION_ACTIVITY_SEVEN_POWER_REWARD',search_date,'all_action',server_id) for _server_list in seven_lv_data: for _action_dict in _server_list: log_time = _action_dict['log_time'].strftime('%Y-%m-%d') if _action_dict['seven_power_id'] == 1 : first += 1 elif _action_dict['seven_power_id'] == 2 : second += 1 elif _action_dict['seven_power_id'] == 3 : third += 1 elif _action_dict['seven_power_id'] == 4 : fourth += 1 row = [log_time,first, second, third, fourth] table_lst.append(row) return table_lst
def make_action_file(search_date,server_id): global first, second, third, fourth # 取事件的文件 row = [] table_lst = [] seven_lv_data = dat_log_util.read_one_day_data('EVENT_ACTION_ACTIVITY_SEVEN_LEVEL_REWARD',search_date,'all_action',server_id) for _server_list in seven_lv_data: for _action_dict in _server_list: log_time = _action_dict['log_time'].strftime('%Y-%m-%d') if _action_dict['seven_level_id'] == 1 : first += 1 elif _action_dict['seven_level_id'] == 2 : second += 1 elif _action_dict['seven_level_id'] == 3 : third += 1 elif _action_dict['seven_level_id'] == 4 : fourth += 1 row = [log_time,first, second, third, fourth] table_lst.append(row) return table_lst
def make_action_file(search_date,server_id): global first, second, third, fourth,fifth,sixth,seventh # 取事件的文件 table_lst = [] row = [] all_dict = dat_log_util.read_one_day_data('EVENT_ACTION_ACTIVITY_STONE_CONSUMPTION_REWARD',search_date,'all_action',server_id) for _server_list in all_dict: for _action_dict in _server_list: log_time = _action_dict['log_time'].strftime('%Y-%m-%d') if _action_dict['activity_tid'] == 1 : first += 1 elif _action_dict['activity_tid'] == 2 : second += 1 elif _action_dict['activity_tid'] == 3 : third += 1 elif _action_dict['activity_tid'] == 4 : fourth += 1 elif _action_dict['activity_tid'] == 5 : fifth += 1 elif _action_dict['activity_tid'] == 6 : sixth += 1 elif _action_dict['activity_tid'] == 7 : seventh += 1 row = [log_time,first, second, third, fourth,fifth,sixth,seventh] table_lst.append(row) return table_lst
def make_action_file(search_date, server_id): global first, second, third, fourth, fifth, sixth, seventh # 取事件的文件 table_lst = [] row = [] all_dict = dat_log_util.read_one_day_data( 'EVENT_ACTION_ACTIVITY_STONE_CONSUMPTION_REWARD', search_date, 'all_action', server_id) for _server_list in all_dict: for _action_dict in _server_list: log_time = _action_dict['log_time'].strftime('%Y-%m-%d') if _action_dict['activity_tid'] == 1: first += 1 elif _action_dict['activity_tid'] == 2: second += 1 elif _action_dict['activity_tid'] == 3: third += 1 elif _action_dict['activity_tid'] == 4: fourth += 1 elif _action_dict['activity_tid'] == 5: fifth += 1 elif _action_dict['activity_tid'] == 6: sixth += 1 elif _action_dict['activity_tid'] == 7: seventh += 1 row = [ log_time, first, second, third, fourth, fifth, sixth, seventh ] table_lst.append(row) return table_lst
def make_action_file(search_date, server_id): new_log_lst = dat_log_util.read_one_day_data("USER_DETAIL", search_date, 'tables', server_id) print len(new_log_lst)
def make_action_file(search_date, server_id): new_log_lst = dat_log_util.read_one_day_data("USER_DETAIL",search_date,'tables',server_id) print len(new_log_lst)