Example #1
0
def recommentation_in(input_ts, recomment_type, submit_user):
    date = ts2datetime(input_ts)
    recomment_results = []
    # read from redis
    results = []
    hash_name = 'recomment_'+str(date) + "_" + recomment_type
    identify_in_hashname = "identify_in_" + str(date)
    submit_user_recomment = "recomment_" + submit_user + "_" + str(date) # 用户自推荐名单
    results = r.hgetall(hash_name)
    if not results:
        return []
    # search from user_profile to rich the show information
    recommend_list = set(r.hkeys(hash_name))
    identify_in_list = set(r.hkeys("compute"))
    submit_user_recomment = set(r.hkeys(submit_user_recomment))
    recomment_results = list(recommend_list - identify_in_list)
    recomment_results = list(set(recomment_results) - submit_user_recomment)

    if recomment_results:
        results = get_user_detail(date, recomment_results, 'show_in', recomment_type)
    else:
        results = []
    #test
    '''
    f = open('/home/user_portrait_0320/revised_user_portrait/user_portrait/user_portrait/recommentation/influence_recommend.csv', 'wb')
    writer = csv.writer(f)
    for item_result in results:
        writer.writerow(item_result)
    f.close()
    '''
    return results
Example #2
0
def show_in_history(date):
    results = []
    hash_name = 'recomment_'+str(date)
    r_results = r.hgetall(hash_name)
    if r_results:
        results = get_user_detail(date, r_results, 'show_in_history')
    return results
Example #3
0
def recommentation_in(input_ts, recomment_type, submit_user):
    date = ts2datetime(input_ts)
    recomment_results = []
    # read from redis
    results = []
    hash_name = 'recomment_' + str(date) + "_" + recomment_type
    identify_in_hashname = "identify_in_" + str(date)
    submit_user_recomment = "recomment_" + submit_user + "_" + str(
        date)  # 用户自推荐名单
    results = r.hgetall(hash_name)
    if not results:
        return []
    # search from user_profile to rich the show information
    recommend_list = set(r.hkeys(hash_name))
    identify_in_list = set(r.hkeys("compute"))
    submit_user_recomment = set(r.hkeys(submit_user_recomment))
    recomment_results = list(recommend_list - identify_in_list)
    recomment_results = list(set(recomment_results) - submit_user_recomment)

    if recomment_results:
        results = get_user_detail(date, recomment_results, 'show_in',
                                  recomment_type)
    else:
        results = []
    return results
Example #4
0
def show_in_history(date, user_type):
    results = []
    #hash_name = 'recomment_'+str(date)
    identify_in_hashname = "identify_in_" + str(date)
    r_results = r.hgetall(identify_in_hashname)
    if r_results:
        results = get_user_detail(date, r_results, 'show_in_history', user_type)
    return results
def show_in_history(date, user_type):
    results = []
    #hash_name = 'recomment_'+str(date)
    identify_in_hashname = "identify_in_" + str(date)
    r_results = r.hgetall(identify_in_hashname)
    if r_results:
        results = get_user_detail(date, r_results, 'show_in_history', user_type)
    return results
def get_attr(date):
    results = {}
    overview_result = r.hgetall(hash_name)
    for item in overview_result:
        value = overview_result[item]
        if isinstance(value, str):
            value = json.loads(value)
        results[item] = value
    return results
def identify_compute(data):
    results = False
    compute_status = 1
    hash_name = 'compute'
    uid2compute = r.hgetall(hash_name)
    for item in data:
        uid = item[1]
        result = r.hget(hash_name, uid)
        in_date = json.loads(result)[0]
        r.hset(hash_name, uid, json.dumps([in_date, compute_status]))

    return True
Example #8
0
def identify_compute(data):
    results = False
    compute_status = 1
    hash_name = 'compute'
    uid2compute = r.hgetall(hash_name)
    for item in data:
        uid = item[1]
        result = r.hget(hash_name, uid)
        in_date = json.loads(result)[0]
        r.hset(hash_name, uid, json.dumps([in_date, compute_status]))

    return True
Example #9
0
def get_attr(date):
    results = {}
    overview_result = r.hgetall(hash_name)
    #print 'overview_result:', overview_result
    for item in overview_result:
        value = overview_result[item]
        if isinstance(value, str):
            value = json.loads(value)
            '''
            if item in rank_field:
                value = value[:5]
            '''
        results[item] = value
    #print 'overview result:', results
    return results
Example #10
0
def recommentation_in(input_ts):
    date = ts2datetime(input_ts)
    recomment_results = []
    # read from redis
    results = []
    hash_name = 'recomment_'+str(date)
    results = r.hgetall(hash_name)
    if not results:
        return results
    # search from user_profile to rich the show information
    for item in results:
        status = results[item]
        if status=='0':
            recomment_results.append(item)
    if recomment_results:
        results = get_user_detail(date, recomment_results, 'show_in')
    else:
        results = []
    return results
Example #11
0
def recommentation_in(input_ts, recomment_type):
    date = ts2datetime(input_ts)
    recomment_results = []
    # read from redis
    results = []
    hash_name = 'recomment_'+str(date) + "_" + recomment_type
    identify_in_hashname = "identify_in_" + str(date)
    results = r.hgetall(hash_name)
    if not results:
        return []
    # search from user_profile to rich the show information
    recommend_list = set(r.hkeys(hash_name))
    identify_in_list = set(r.hkeys("compute"))
    recomment_results = list(recommend_list - identify_in_list)

    if recomment_results:
        results = get_user_detail(date, recomment_results, 'show_in', recomment_type)
    else:
        results = []
    return results
Example #12
0
def admin_recommentation_in(input_ts):
    date = ts2datetime(input_ts)
    recomment_results = []
    identify_in_hashname = "identify_in_" + str(date)
    # read from redis
    results = []
    hashname_submit = "submit_recomment_" + date
    results = r.hgetall(hashname_submit)
    if not results:
        return []
    # search from user_profile to rich the show information
    submit_set = set(r.hkeys(hashname_submit))
    idntify_in_set = set(r.hkeys("compute")) # 已入库用户名单
    recomment_results = list(submit_set - idntify_in_set) #过滤一下
    if recomment_results:
        results = get_user_detail(date, recomment_results, 'show_in', "sensitive", "admin")
        sorted_results = sorted(results, key=lambda x:x[-1], reverse=True)
        results = sorted_results
    else:
        results = []
    return results
Example #13
0
def admin_recommentation_in(input_ts):
    date = ts2datetime(input_ts)
    recomment_results = []
    identify_in_hashname = "identify_in_" + str(date)
    # read from redis
    results = []
    hashname_submit = "submit_recomment_" + date
    results = r.hgetall(hashname_submit)
    if not results:
        return []
    # search from user_profile to rich the show information
    submit_set = set(r.hkeys(hashname_submit))
    idntify_in_set = set(r.hkeys("compute")) # 已入库用户名单
    recomment_results = list(submit_set - idntify_in_set) #过滤一下
    if recomment_results:
        results = get_user_detail(date, recomment_results, 'show_in', "sensitive", "admin")
        sorted_results = sorted(results, key=lambda x:x[-1], reverse=True)
        results = sorted_results
    else:
        results = []
    return results
Example #14
0
def show_compute(date):
    results = []
    hash_name = 'compute'
    r_results = r.hgetall(hash_name)
    input_data = {}
    #search user profile to inrich information
    if r_results and date!='all':
        for user in r_results:
            item = r_results[user]
            in_date = json.loads(item)[0]
            if in_date == date:
                input_data[user] = item
        if input_data:
            results = get_user_detail(date, input_data, 'show_compute')
        else:
            results = []
        return results
    elif r_results and date=='all':
        results = get_user_detail(date, r_results, 'show_compute')
        return results
    else:
        return results
Example #15
0
def show_compute(date):
    results = []
    hash_name = 'compute'
    r_results = r.hgetall(hash_name)
    input_data = {}
    #search user profile to inrich information
    if r_results and date!='all':
        for user in r_results:
            item = r_results[user]
            in_date = json.loads(item)[0]
            if in_date == date:
                input_data[user] = item
        if input_data:
            results = get_user_detail(date, input_data, 'show_compute')
        else:
            results = []
        return results
    elif r_results and date=='all':
        results = get_user_detail(date, r_results, 'show_compute')
        return results
    else:
        return results
Example #16
0
def get_importance_top():
    overview_result = r.hgetall(hash_name)
    importance_top = json.loads(overview_result['top_importance'])
    return importance_top
Example #17
0
def get_retweeted_top():
    overview_result = r.hgetall(hash_name)
    retweeted_top = json.loads(overview_result['top_retweeted_user'])
    return retweeted_top
Example #18
0
def get_online_pattern():
    overview_result = r.hgetall(hash_name)
    online_pattern = json.loads(overview_result['online_pattern_top'])
    return online_pattern
Example #19
0
def get_importance_top():
    overview_result = r.hgetall(hash_name)
    importance_top = json.loads(overview_result['top_importance'])
    return importance_top
Example #20
0
def get_activeness_top():
    overview_result = r.hgetall(hash_name)
    activeness_top = json.loads(overview_result['top_activeness'])
    return activeness_top
Example #21
0
def get_comment_top():
    overview_result = r.hgetall(hash_name)
    comment_top = json.loads(overview_result['top_comment_user'])
    return comment_top
Example #22
0
def get_retweeted_top():
    overview_result = r.hgetall(hash_name)
    retweeted_top = json.loads(overview_result['top_retweeted_user'])
    return retweeted_top
Example #23
0
def get_hashtag_top():
    overview_result = r.hgetall(hash_name)
    hashtag_top = json.loads(overview_result['hashtag_top'])
    return hashtag_top
Example #24
0
def get_online_pattern():
    overview_result = r.hgetall(hash_name)
    online_pattern = json.loads(overview_result['online_pattern_top'])
    return online_pattern
Example #25
0
def get_geo_top():
    overview_result = r.hgetall(hash_name)
    geo_top = json.loads(overview_result['activity_geo_top'])
    return geo_top
Example #26
0
def get_hashtag_top():
    overview_result = r.hgetall(hash_name)
    hashtag_top = json.loads(overview_result['hashtag_top'])
    return hashtag_top
Example #27
0
def get_geo_top():
    overview_result = r.hgetall(hash_name)
    geo_top = json.loads(overview_result['activity_geo_top'])
    return geo_top
Example #28
0
def get_comment_top():
    overview_result = r.hgetall(hash_name)
    comment_top = json.loads(overview_result['top_comment_user'])
    return comment_top
Example #29
0
def get_activeness_top():
    overview_result = r.hgetall(hash_name)
    activeness_top = json.loads(overview_result['top_activeness'])
    return activeness_top