예제 #1
0
def rcmd_from_queue(uid):
    '''从优先队列里进行推荐'''
    key = keys.FIRST_RCMD_Q % uid
    uid_list = rds.lrange(key, 0, 19)  # 从Redis 取出 优先推荐的用户 ID
    # 这里取出来的都是 bytes 类型的数据, 还需要强转成 int
    uid_list = [int(r_uid) for r_uid in uid_list]  # 将uid 列表元素
    return User.objects.filter(id__in=uid_list)
예제 #2
0
def rcmd_from_queue(uid):
    '''优先从喜欢我的人队列里面进行推荐'''
    uid_list = rds.lrange(keys.FIRST_RCMD_Q % uid, 0, 19)
    # 从优先推荐队列取出uid列表
    # lrange是redis的获取数据
    # 左避右避
    uid_list = [int(uid) for uid in uid_list]  # 将二进制uid强转成int类型
    return User.objects.filter(id__in=uid_list)
예제 #3
0
def rcmd_from_queue(uid):
    '''从推荐列表进行推荐'''
    # 结果是2进制列表,取20个
    uid_list = rds.lrange(keys.FIRST_RCMD_Q % uid, 0, 19)
    # 转换成int类型
    uid_list = [int(uid) for uid in uid_list]

    users = User.objects.filter(id__in=uid_list)
    return users
예제 #4
0
파일: logics.py 프로젝트: nhnba/nhnba_one
def rcmd_from_queue(uid):
    '''从优先推荐队列进行推荐'''
    uid_list = rds.lrange(keys.FIRST_RCMD_Q % uid, 0, 19)  # 从优先推荐队列取出 uid 列表
    uid_list = [int(uid) for uid in uid_list]  # 将 uid 强转成 int 类型
    return User.objects.filter(id__in=uid_list)
예제 #5
0
def rcmd_from_rds(uid):
    '''取出优先推荐队列的用户'''
    uid_list = rds.lrange(keys.FIRST_RCMD_K % uid, 0, 29)
    uid_list = [int(uid) for uid in uid_list]
    return User.objects.filter(id__in=uid_list)
예제 #6
0
def first_rcmd(uid):
    """从Redis的优秀推荐列表中获取要推荐的用户"""
    uid_list = rds.lrange(keys.FIRST_RCMD_K % uid, 0, 20)
    uid_list = [int(uid) for uid in uid_list]  # 将uid_list中的bytes强转成int
    return User.objects.filter(id__in=uid_list)
예제 #7
0
파일: logics.py 프로젝트: yaowuwu/Gaoziyi
def rcmd_users_from_q(uid):
    '''从优先队列中获取推荐对象'''
    name = keys.FIRST_RCMD_Q % uid
    uid_list = rds.lrange(name, 0, 24)
    uid_list = [int(uid) for uid in uid_list]
    return User.objects.filter(id__in=uid_list)
예제 #8
0
def rcmd_from_queue(uid):
    '''从优先推荐队列里推荐用户'''
    uid_list = rds.lrange(keys.FIRST_RCMD_Q + str(f'{uid}'), 0, 19)  # 从优先推荐队列取出uid
    uid_list = [int(uid) for uid in uid_list]
    return User.objects.filter(id__in=uid_list)
예제 #9
0
def first_rcmd(uid):
    '''从redis的优先推荐列表中获取要推荐的用户'''
    uid_list = rds.lrange(keys.FIRST_CRMD_K % uid, 0, 19)
    uid_list = [int(uid) for uid in uid_list]  # 将uid_list中的bytes强转成int
    return User.objects.filter(id__in=uid_list)
예제 #10
0
def rcmd_from_list(user_id):
    '''从优先推荐列表取出滑动用户'''
    uid_list = rds.lrange(keys.PRIOR_RCMD_LIST % user_id, 0, 19)
    uid_list = [int(uid) for uid in uid_list]  # 将bytes类型强转为int类型
    users = User.objects.filter(id__in=uid_list)
    return users
예제 #11
0
def users_from_rds(uid):
    """从Redis中提取用户"""
    user_id_list = rds.lrange(keys.FIRST_RCMD_K % uid, 0, 19)
    users = [user for user in User.objects.filter(id__in=user_id_list)]
    return users