Пример #1
0
    def get_important_friends(cls, user_id, max_lookup=500, limit=100):
        a = Account._byID(user_id, data=True)
        # friends are returned chronologically by date, so pick the end of the list
        # for the most recent additions
        friends = Account._byID(a.friends[-max_lookup:], return_dict=False, data=True)

        # if we don't have a last visit for your friends, we don't
        # care about them
        last_visits = last_modified_multi(friends, "submitted")
        friends = [x for x in friends if x in last_visits]

        # sort friends by most recent interactions
        friends.sort(key=lambda x: last_visits[x], reverse=True)
        return [x._id for x in friends[:limit]]
Пример #2
0
    def get_important_friends(cls, user_id, max_lookup = 500, limit = 100):
        a = Account._byID(user_id, data = True)
        # friends are returned chronologically by date, so pick the end of the list
        # for the most recent additions
        friends = Account._byID(a.friends[-max_lookup:], return_dict = False,
                                data = True)

        # if we don't have a last visit for your friends, we don't
        # care about them
        last_visits = last_modified_multi(friends, "submitted")
        friends = [x for x in friends if x in last_visits]

        # sort friends by most recent interactions
        friends.sort(key = lambda x: last_visits[x], reverse = True)
        return [x._id for x in friends[:limit]]