From b252769a4d7fa1773820df7eacd17f863ecdedb9 Mon Sep 17 00:00:00 2001 From: Flancian <0@flancia.org> Date: Sun, 10 Jan 2021 21:10:13 +0100 Subject: [PATCH] Fix ranking of images. --- app/util.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/util.py b/app/util.py index 9b9efb3..35f75e5 100644 --- a/app/util.py +++ b/app/util.py @@ -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)