def wave_rate_hour(): data = get_data_from_db() date_init = datetime.datetime(2014, 10, 20, 13, 36, 00) date_delta = data[0]['update_time'] - date_init hour = date_delta.seconds / 3600 + date_delta.days * 24 dict = {} dict['init'] = {'change_num': 0, 'count': 0} change_num = 0 count = 0 for i in range(len(data)): if dict.has_key(data[i]['source']): dict[data[i]['source']]['change_num'] = int( dict[data[i]['source']]['change_num']) + int( data[i]['change_num']) dict[data[i] ['source']]['count'] = dict[data[i]['source']]['count'] + 1 else: dict[data[i]['source']] = { 'change_num': int(data[i]['change_num']), 'count': 1 } dict_source_wave = {} del dict['init'] for key in dict.keys(): hour_wave = (hour * dict[key]['count']) / dict[key]['change_num'] dict_source_wave[key] = hour_wave print dict_source_wave return dict_source_wave
def wave_rate_hour(): data = get_data_from_db() date_init = datetime.datetime(2014,10,20,13,36,00) date_delta = data[0]['update_time'] - date_init hour = date_delta.seconds/3600 + date_delta.days * 24 dict = { } dict['init'] = {'change_num':0,'count':0} change_num = 0 count = 0 for i in range(len(data)): if dict.has_key(data[i]['source']): dict[data[i]['source']]['change_num'] = int(dict[data[i]['source']]['change_num']) + int(data[i]['change_num']) dict[data[i]['source']]['count'] = dict[data[i]['source']]['count'] + 1 else: dict[data[i]['source']] = {'change_num':int(data[i]['change_num']),'count':1} dict_source_wave = {} del dict['init'] for key in dict.keys(): hour_wave = (hour * dict[key]['count'])/dict[key]['change_num'] dict_source_wave[key] = hour_wave print dict_source_wave return dict_source_wave
def task_num_per_day(): dict = task_total_num() for key in dict.keys(): dict[key] = dict[key]/70.00 print dict
def task_num_per_day(): dict = task_total_num() for key in dict.keys(): dict[key] = dict[key] / 70.00 print dict