Beispiel #1
0
    def test_get_user_following(self):
        user1 = backend.add_user('username01','photo_url01','weibo_id01')
        user2 = backend.add_user('username02','photo_url02','weibo_id02')
        user3 = backend.add_user('username03','photo_url03','weibo_id03')

        backend.follow_user(user1['id'],user2['id'])
        backend.follow_user(user1['id'],user3['id'])

        users = backend.get_user_following(user1['id'])
        assert len(users) == 2

        count = backend.get_user_following_count(user1['id'])
        assert count == 2
Beispiel #2
0
    def test_get_user_following(self):
        user1 = backend.add_user('username01', 'photo_url01', 'weibo_id01')
        user2 = backend.add_user('username02', 'photo_url02', 'weibo_id02')
        user3 = backend.add_user('username03', 'photo_url03', 'weibo_id03')

        backend.follow_user(user1['id'], user2['id'])
        backend.follow_user(user1['id'], user3['id'])

        users = backend.get_user_following(user1['id'])
        assert len(users) == 2

        count = backend.get_user_following_count(user1['id'])
        assert count == 2
Beispiel #3
0
    def get(self, user_id):
        user = backend.get_user(user_id)

        user_following_count = backend.get_user_following_count(user_id)
        user_follower_count = backend.get_user_follower_count(user_id)
        user_post_count = backend.get_user_post_count(user_id)
        user_liked_post_count = backend.get_user_liked_post_count(user_id)

        curr_user = backend.get_user_by_uid(g.ukey)

        is_follow = backend.is_following_user(curr_user['id'], user_id)

        pd = {
            'is_follow': is_follow,
            'following_count': user_following_count,
            'follower_count': user_follower_count,
            'post_count': user_post_count,
            'liked_post_count': user_liked_post_count
        }
        user.update(pd)
        return jsonify(**user)
Beispiel #4
0
    def get(self,user_id):
        user = backend.get_user(user_id)

        user_following_count = backend.get_user_following_count(user_id)
        user_follower_count = backend.get_user_follower_count(user_id)
        user_post_count = backend.get_user_post_count(user_id)
        user_liked_post_count = backend.get_user_liked_post_count(user_id)

        curr_user = backend.get_user_by_uid(g.ukey)

        is_follow = backend.is_following_user(curr_user['id'],user_id)
        
        pd = {
                'is_follow':is_follow,
                'following_count':user_following_count,
                'follower_count':user_follower_count,
                'post_count':user_post_count,
                'liked_post_count':user_liked_post_count
                }
        user.update(pd)
        return jsonify(**user)
Beispiel #5
0
    def get(self,user_id):
        try:
            page = int(request.values.get('page'))
        except:
            page = 1

        limit = 50
        offset = (page-1) * 50

        following_users = backend.get_user_following(user_id,limit=limit,
                                offset=offset)

        curr_user = backend.get_user_by_uid(g.ukey)

        fids = [u['id'] for u in following_users]
        fdict = backend.is_following_user(curr_user['id'],fids)
        for fu in following_users:
            fu['follower_count'] = backend.get_user_follower_count(fu['id'])
            fu['is_follow'] = fdict.get(fu['id']) or False
        count = backend.get_user_following_count(user_id)
        total_page = (count + 49) / 50
        return jsonify(users=following_users,page=page,total_page=total_page)
Beispiel #6
0
    def get(self, user_id):
        try:
            page = int(request.values.get('page'))
        except:
            page = 1

        limit = 50
        offset = (page - 1) * 50

        following_users = backend.get_user_following(user_id,
                                                     limit=limit,
                                                     offset=offset)

        curr_user = backend.get_user_by_uid(g.ukey)

        fids = [u['id'] for u in following_users]
        fdict = backend.is_following_user(curr_user['id'], fids)
        for fu in following_users:
            fu['follower_count'] = backend.get_user_follower_count(fu['id'])
            fu['is_follow'] = fdict.get(fu['id']) or False
        count = backend.get_user_following_count(user_id)
        total_page = (count + 49) / 50
        return jsonify(users=following_users, page=page, total_page=total_page)