示例#1
0
    def _get_suggested_books(self):
        mongo = MongoApi()
        msuggestions = mongo.get_suggested_books(self.user)

        suggestions = []
        for isbn, count in msuggestions:
            book = Book.objects.get(isbn=isbn)
            suggestions.append((book, count))

        return suggestions    
示例#2
0
    def refresh_social_suggestions(self, reset=False):

        cbooks = {}

        for u in self.connections:
            for book in u.user_profile.books.all():
                if book.isbn in cbooks:
                    cbooks[book.isbn] += 1
                else:
                    cbooks[book.isbn] = 1

        

        #save in mongodb            
        mongo = MongoApi()
        catalog_isbns = [book.isbn for book in self.user.user_profile.books.all()]
        mongo.refresh_social_suggestions(self.user, cbooks, catalog_isbns, reset)

        return cbooks