def test_get_and_set_exploration_recommendations(self):
        recommended_exp_ids = ["exp_id_2", "exp_id_3"]
        recommendations_services.set_recommendations("exp_id_1", recommended_exp_ids)
        saved_recommendation_ids = recommendations_services.get_exploration_recommendations("exp_id_1")
        self.assertEqual(recommended_exp_ids, saved_recommendation_ids)

        recommended_exp_ids = ["exp_id_3"]
        recommendations_services.set_recommendations("exp_id_1", recommended_exp_ids)
        saved_recommendation_ids = recommendations_services.get_exploration_recommendations("exp_id_1")
        self.assertEqual(recommended_exp_ids, saved_recommendation_ids)
    def reduce(key, stringified_values):
        other_exploration_similarities = sorted(
            [ast.literal_eval(v) for v in stringified_values],
            reverse=True,
            key=lambda x: x['similarity_score'])

        recommended_exploration_ids = [
            item['exp_id']
            for item in other_exploration_similarities[:MAX_RECOMMENDATIONS]]

        recommendations_services.set_recommendations(
            key, recommended_exploration_ids)
예제 #3
0
    def reduce(key, stringified_values):
        other_exploration_similarities = sorted(
            [ast.literal_eval(v) for v in stringified_values],
            reverse=True,
            key=lambda x: x['similarity_score'])

        recommended_exploration_ids = [
            item['exp_id']
            for item in other_exploration_similarities[:MAX_RECOMMENDATIONS]]

        recommendations_services.set_recommendations(
            key, recommended_exploration_ids)
예제 #4
0
    def reduce(key, stringified_values):
        from core.domain import recommendations_services

        MAX_RECOMMENDATIONS = 10

        other_exploration_similarities = sorted(
            [ast.literal_eval(v) for v in stringified_values], reverse=True, key=lambda x: x["similarity_score"]
        )

        recommended_exploration_ids = [item["exp_id"] for item in other_exploration_similarities[:MAX_RECOMMENDATIONS]]

        recommendations_services.set_recommendations(key, recommended_exploration_ids)
    def test_get_and_set_exploration_recommendations(self):
        recommended_exp_ids = ['exp_id_2', 'exp_id_3']
        recommendations_services.set_recommendations('exp_id_1',
                                                     recommended_exp_ids)
        saved_recommendation_ids = (
            recommendations_services.get_exploration_recommendations(
                'exp_id_1'))
        self.assertEqual(recommended_exp_ids, saved_recommendation_ids)

        recommended_exp_ids = ['exp_id_3']
        recommendations_services.set_recommendations('exp_id_1',
                                                     recommended_exp_ids)
        saved_recommendation_ids = (
            recommendations_services.get_exploration_recommendations(
                'exp_id_1'))
        self.assertEqual(recommended_exp_ids, saved_recommendation_ids)
    def test_get_and_set_exploration_recommendations(self):
        recommended_exp_ids = ['exp_id_2', 'exp_id_3']
        recommendations_services.set_recommendations(
            'exp_id_1', recommended_exp_ids)
        saved_recommendation_ids = (
            recommendations_services.get_exploration_recommendations(
                'exp_id_1'))
        self.assertEqual(recommended_exp_ids, saved_recommendation_ids)

        recommended_exp_ids = ['exp_id_3']
        recommendations_services.set_recommendations(
            'exp_id_1', recommended_exp_ids)
        saved_recommendation_ids = (
            recommendations_services.get_exploration_recommendations(
                'exp_id_1'))
        self.assertEqual(recommended_exp_ids, saved_recommendation_ids)