Ejemplo n.º 1
0
def get_recommendations(request):
    start = int(request.GET.get('start', 0))
    length = int(request.GET.get('count', 50))
    channels = api_utils.get_recommendations(
                                             request.user, start, length)
    return response_for_data(request, map(data_for_channel,
                                          channels))
Ejemplo n.º 2
0
    def test_get_recommendations(self):
        rating, created = Rating.objects.get_or_create(
            channel=self.channels[0], user=self.owner)
        rating.rating = 5
        rating.save()

        call_command('refresh_stats_table')
        call_command('calculate_recommendations')

        channels = utils.get_recommendations(self.owner)
        self.assertEquals(len(channels), 1)
        self.assertEquals(channels[0].id, self.channels[1].id)
        self.assertEquals(channels[0].guessed, 5.0)
        self.assertEquals(len(channels[0].reasons), 1)
        self.assertEquals(channels[0].reasons[0].id, self.channels[0].id)
        self.assertTrue(channels[0].reasons[0].score > 0.5)
Ejemplo n.º 3
0
    def test_get_recommendations(self):
        rating, created = Rating.objects.get_or_create(
            channel=self.channels[0], user=self.owner)
        rating.rating = 5
        rating.save()

        call_command('refresh_stats_table')
        call_command('calculate_recommendations')

        channels = utils.get_recommendations(self.owner)
        self.assertEquals(len(channels), 1)
        self.assertEquals(channels[0].id, self.channels[1].id)
        self.assertEquals(channels[0].guessed, 5.0)
        self.assertEquals(len(channels[0].reasons), 1)
        self.assertEquals(channels[0].reasons[0].id, self.channels[0].id)
        self.assertTrue(channels[0].reasons[0].score > 0.5)
Ejemplo n.º 4
0
 def items(self, user):
     return api_utils.get_recommendations(user)
Ejemplo n.º 5
0
 def items(self, user):
     return api_utils.get_recommendations(user)
Ejemplo n.º 6
0
def get_recommendations(request):
    start = int(request.GET.get('start', 0))
    length = int(request.GET.get('count', 50))
    channels = api_utils.get_recommendations(request.user, start, length)
    return response_for_data(request, map(data_for_channel, channels))