leaderboards: fix usernames in tables i think

i'm not *happy* about this, something seems inelegant about this solution...
remotes/1693176582716663532/tmp_refs/heads/watchparty
justcool393 2022-11-01 02:17:33 -05:00
parent 55c8ce6e9d
commit 9048f5127d
2 changed files with 4 additions and 2 deletions

View File

@ -17,6 +17,7 @@ class Leaderboard:
all_users = None
v_position = 0
v_value = None
user_func = None
value_func = None
def __init__(self, header_name:str, table_header_name:str, html_id:str, table_column_name:str,
@ -33,9 +34,11 @@ class Leaderboard:
self.v_position = lb[1]
self.v_value = lb[2]
if value_func:
self.user_func = lambda u:u
self.value_func = value_func
self.v_value = value_func(v)
else:
self.user_func = lambda u:u[0]
self.value_func = lambda u: u[1] or 0
@classmethod
@ -94,4 +97,3 @@ class Leaderboard:
if not position: position = (leaderboard.count() + 1, 0)
leaderboard = leaderboard.limit(limit).all()
return (leaderboard, position[0], position[1])

View File

@ -40,7 +40,7 @@
{% if v.id == user.id %}
{% set style="class=\"self\"" %}
{% endif %}
{{format_user_in_table(user, style, loop.index, lb.value_func(user), lb.user_relative_url)}}
{{format_user_in_table(lb.user_func(user), style, loop.index, lb.value_func(user), lb.user_relative_url)}}
{% endfor %}
{% if lb.v_position %}
{{format_user_in_table(v, "style=\"border-top:2px solid var(--primary)\"", lb.v_position, lb.v_value, lb.user_relative_url)}}