def push_create_community(): #判断日期,等于0表示是周一 from datetime import datetime dayOfWeek = datetime.today().weekday() #生成日期-周日 datetime = int(time.time()) - DAY #虚拟人列表 xnr_user_no_list = get_compelete_wbxnr() if dayOfWeek == 0: weibo_community_mappings(ts2datetime(datetime)) for xnr_user_no in xnr_user_no_list: weibo_trace_community_mappings(xnr_user_no) #判断当天状态表情况 status_mark = get_day_status(xnr_user_no, datetime) if status_mark < 0: task_dict = dict() task_dict['xnr_user_no'] = xnr_user_no task_dict['datetime'] = datetime #将计算任务加入队列 r_community.lpush(weibo_community_find_task_queue_name, json.dumps(task_dict)) print '已经把生成社区任务加入队列!!!'
def push_trace_community(): #判断日期,等于0表示是周一 from datetime import datetime dayOfWeek = datetime.today().weekday() #生成日期-周日 datetime = int(time.time()) - DAY #社区列表 community_list = get_trace_community(datetime) #虚拟人列表 xnr_user_no_list = get_compelete_wbxnr() if dayOfWeek != 0: for community in community_list: task_dict = dict() task_dict['community'] = community task_dict['datetime'] = datetime #将计算任务加入队列 r_community.lpush(weibo_community_trace_task_queue_name, json.dumps(task_dict)) else: num = 0 for xnr_user_no in xnr_user_no_list: status_mark = get_day_status(xnr_user_no, datetime) num = num + status_mark if num == len(xnr_user_no_list): for community in community_list: task_dict = dict() task_dict['community'] = community task_dict['datetime'] = datetime #将计算任务加入队列 r_community.lpush(weibo_community_trace_task_queue_name, json.dumps(task_dict)) print '已经把跟踪社区任务加入队列!!!'
def create_weibo_community(): if S_TYPE == 'test': today_time = datetime2ts(WEIBO_COMMUNITY_DATE) xnr_user_no_list = ['WXNR0004'] else: today_time = time.time() xnr_user_no_list = get_compelete_wbxnr() # xnr_user_no_list = ['WXNR0004'] for xnr_user_no in xnr_user_no_list: #给定的nodes可能会因为网络结构或排序被删掉 s = time.time() #得到划分的社区 G, allG, coms_list = find_from_uid_list(xnr_user_no) print 'group evaluate...' all_influence = get_evaluate_max(influence_index, influence_type, 'bci_week_ave') all_sensitive = get_evaluate_max(sensitive_index, sensitive_type, 'sensitive_week_ave') print 'allG nodes:', allG.number_of_nodes() print 'G nodes:', G.number_of_nodes() file_path = './weibo_data/' + xnr_user_no + '_' + ts2datetime( today_time) + '_' + 'save_com.json' print 'file_path:', file_path f = open(file_path, 'w') for k, v in enumerate(coms_list): #计算评价指标 f.write( json.dumps( group_evaluate(xnr_user_no, v, all_influence, all_sensitive, G)) + '\n') print 'total time:', time.time() - s print 'eq:', ExtendQ(allG, coms_list)
print 'newnew!!!' for new_community in create_communitylist: new_community['community_status'] = 1 result_mark = save_community_detail(new_community, date_time) return result_mark if __name__ == '__main__': # start_time = int(time.time()) # xnr_user_no = 'WXNR0004' # date_time = datetime2ts('2018-03-13') # # get_select_community(xnr_user_no,date_time) # uid_list = ["3623353053", "5269743490", "3847403453", "5461392052", "5935891935", "2684793101", "5889425309", "2947335715", "5677806677", "5857120687", "2141246805", "1646029765", "1710173801", "5897716478", "5796731205", "5080620052", "5843802987", "5874487882", "5337758780", "6052732011", "1836308272", "2520614617", "5237810007", "3200673035", "5305142622", "5113031562", "2782682084", "2482242324", "5889618968", "5754076274"] # # get_community_coreuser_socail(uid_list,datetime2ts(date_time)) # # end_time = int(time.time()) # # print 'time_cost:',end_time - start_time # core_uidlist = ["3623353053", "5269743490", "3847403453"] # outer_uidlist = [ "5586779165", "1236103277"] # get_community_userinfo(uid_list,core_uidlist,outer_uidlist) if S_TYPE == 'test': datetime = datetime2ts(WEIBO_COMMUNITY_DATE) xnr_user_no_list = ['WXNR0004'] else: datetime = int(time.time()) xnr_user_no_list = get_compelete_wbxnr() start_time = int(time.time()) for xnr_user_no in xnr_user_no_list: get_final_community(xnr_user_no, datetime) end_time = int(time.time()) print 'cost_time::', end_time - start_time