Fix sort key error
This commit is contained in:
parent
e9725d27aa
commit
5c6391fb76
2 changed files with 5 additions and 4 deletions
|
@ -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]
|
|
@ -646,7 +646,8 @@ 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
|
||||
|
|
Loading…
Reference in a new issue