Esempio n. 1
0
def login_status(xnr_user_no):
	
	group_dict = getgroup_v2(xnr_user_no)
	print 'group_dict======',group_dict
	if group_dict:
		login_status = 'True'
	else:
		login_status = 'False'
	return login_status
Esempio n. 2
0
def login_status(xnr_user_no):

    group_dict = getgroup_v2(xnr_user_no)

    if group_dict:
        login_status = True
    else:
        login_status = False

    return login_status
Esempio n. 3
0
def show_qq_xnr(MAX_VALUE):
    query_body = {'query': {'match_all': {}}, 'size': MAX_VALUE}
    results = []
    result = es_xnr.search(index=qq_xnr_index_name,
                           doc_type=qq_xnr_index_type,
                           body=query_body)['hits']['hits']
    qq_xnr_list = []
    for item in result:
        item_dict = dict()
        temp = item['_source'].copy()
        item_dict = dict(item_dict, **temp)
        #step1: identify login status
        port = item['_source']['qqbot_port']
        qqnum = item['_source']['qq_number']
        xnr_user_no = item['_source']['xnr_user_no']
        group_dict = getgroup_v2(xnr_user_no)
        print 'group_dict:::', group_dict
        if group_dict:
            login_status = True
        else:
            login_status = False
        item_dict['login_status'] = login_status
        now_date = ts2datetime(time.time() - 24 * 3600)
        #histroy_id = item['_source']['xnr_user_no'] + '_' + now_date
        qq_xnr_history_count_index_name = qq_xnr_history_count_index_name_pre + now_date
        try:
            history_result = es_xnr.get(index=qq_xnr_history_count_index_name,\
                doc_type=qq_xnr_history_count_index_type, id=xnr_user_no)['_source']
            total_post_num = history_result['total_post_num']
            daily_post_num = history_result['daily_post_num']
        except:
            total_post_num = 0
            daily_post_num = 0

        group_message_index_name = group_message_index_name_pre + ts2datetime(
            time.time())

        query_body = {
            'query': {
                'bool': {
                    'must': [{
                        'term': {
                            'speaker_qq_number': qqnum
                        }
                    }, {
                        'term': {
                            'xnr_qq_number': qqnum
                        }
                    }]
                }
            }
        }
        try:
            count_result = es_xnr.count(index=group_message_index_name,
                                        doc_type=group_message_index_type,
                                        body=query_body)

            if count_result['_shards']['successful'] != 0:
                today_count = count_result['count']
            else:
                print 'es index rank error'
                today_count = 0
        except:
            today_count = 0

        item_dict['daily_post_num'] = today_count
        item_dict['total_post_num'] = total_post_num + today_count
        results.append(item_dict)

    return results