Fix ranking of images.

This commit is contained in:
Flancian 2021-01-10 21:10:13 +01:00
parent e7b59f72ee
commit b252769a4d
1 changed files with 7 additions and 2 deletions

View File

@ -23,11 +23,16 @@ def rank(l, user):
def uprank(l, users):
# hack hack
# score is a sorting order; lower comes first.
def score(n):
score = 0
if n.user in users:
# the earlier in the list a user comes, the more highly ranked it is.
return users.index(n.user) - len(users) - 1
return 0
score = users.index(n.user) - len(users) - 1
if n.mediatype != 'text/plain':
# downrank images as wherever a user has both text and image the text probably needs to go first.
score += 0.01
return score
return sorted(l, key=score)