Skip to content
Snippets Groups Projects
Commit 57923aa7 authored by E. Madison Bray's avatar E. Madison Bray
Browse files

[bug] fix popularity-based recommendations on new articles that don't have

any default metrics stored on them
parent c61b66e7
No related branches found
No related tags found
No related merge requests found
......@@ -86,7 +86,11 @@ def popularity(article):
You could replace this with a more sophisticated measure of popularity.
"""
m = article['metrics']
m = article.get('metrics')
if m is None:
# New articles might not have metrics saved on them yet, so the
# default value is just 1
return 1
return max(1, m['clicks']) * max(1, (m['likes'] - m['dislikes']))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment