diff --git a/judge/ml/collab_filter.py b/judge/ml/collab_filter.py index 76f8827..504f9c6 100644 --- a/judge/ml/collab_filter.py +++ b/judge/ml/collab_filter.py @@ -45,7 +45,7 @@ class CollabFilter: if pid < len(scores): res.append((scores[pid], problem)) - res.sort(reverse=True) + res.sort(reverse=True, key=lambda x: x[0]) return res[:limit] @@ -60,5 +60,5 @@ class CollabFilter: for p in problemset: if p.id < len(scores): res.append((scores[p.id], p)) - res.sort(reverse=True) + res.sort(reverse=True, key=lambda x: x[0]) return res[:limit] \ No newline at end of file diff --git a/judge/views/problem.py b/judge/views/problem.py index 25bf526..f58fd11 100644 --- a/judge/views/problem.py +++ b/judge/views/problem.py @@ -646,8 +646,9 @@ class ProblemFeed(FeedView): cl_model = CollabFilter() dot_rec = cl_model.user_recommendations(user, queryset, cl_model.DOT, 100) cosine_rec = cl_model.user_recommendations(user, queryset, cl_model.COSINE, 100) - hot_problems_rec = hot_problems(timedelta(days=7), 10) - + hot_problems_rec = [problem for problem in hot_problems(timedelta(days=7), 10) + if problem in queryset] + q = self.merge_recommendation([dot_rec, cosine_rec, hot_problems_rec]) return q