rDrama/files/classes
TLSM a060f5840c fix: comment score regression
PR #547 introduced a UI bug where the comment score tooltip would
show the wrong values (and in fact, the displayed score was also
wrong, though this was not originally noticed).

Specifically, a comment with e.g. +4 | -1 would display in the tooltip
as being +4 | -4 and display a score of 4. The desired behavior would
be +4 | -1 and score of 3. Precisely, the upvote value was displayed
for each of upvotes, downvotes, and net score.

Root cause was the `@lazy` decorator at:
`files.classes.comment._score_context_str(⋅)`

`@lazy` is very dumb. I don't entirely know why we don't just use
`functools.cache`, but we use `@lazy` everywhere. It is entirely
ignorant of the parameters to a function--not a substitute for
memoization.

comments.html contains the following snippet:

    {%- set ups = c.upvotes_str(render_ctx) -%}
    {%- set score = c.score_str(render_ctx) -%}
    {%- set downs = c.downvotes_str(render_ctx) -%}

Each of those three functions internally calls to `_score_context_str`
but with different arguments. The first call to upvotes gets cached by
`@lazy` and the two subsequent calls get the upvotes string, rather than
what they wanted. It's a cheap enough operation that it's not really
worth memoizing, so we just remove the decorator.
2023-03-15 01:58:15 -05:00
..
__init__.py fix base import 2023-03-14 13:32:47 -05:00
alts.py fix MovedIn20Warning 2023-03-14 13:32:47 -05:00
award.py fix MovedIn20Warning 2023-03-14 13:32:47 -05:00
badges.py fix MovedIn20Warning 2023-03-14 13:32:47 -05:00
base.py fix MovedIn20Warning 2023-03-14 13:32:47 -05:00
clients.py fix MovedIn20Warning 2023-03-14 13:32:47 -05:00
comment.py fix: comment score regression 2023-03-15 01:58:15 -05:00
domains.py fix MovedIn20Warning 2023-03-14 13:32:47 -05:00
exiles.py fix MovedIn20Warning 2023-03-14 13:32:47 -05:00
flags.py fix MovedIn20Warning 2023-03-14 13:32:47 -05:00
follows.py fix MovedIn20Warning 2023-03-14 13:32:47 -05:00
leaderboard.py leaderboard refactor (#526) 2023-02-24 06:31:17 -06:00
marsey.py fix MovedIn20Warning 2023-03-14 13:32:47 -05:00
mod.py fix MovedIn20Warning 2023-03-14 13:32:47 -05:00
mod_logs.py fix MovedIn20Warning 2023-03-14 13:32:47 -05:00
notifications.py fix MovedIn20Warning 2023-03-14 13:32:47 -05:00
saves.py fix MovedIn20Warning 2023-03-14 13:32:47 -05:00
sub.py fix MovedIn20Warning 2023-03-14 13:32:47 -05:00
sub_block.py fix MovedIn20Warning 2023-03-14 13:32:47 -05:00
submission.py fix MovedIn20Warning 2023-03-14 13:32:47 -05:00
subscriptions.py fix MovedIn20Warning 2023-03-14 13:32:47 -05:00
user.py fix base import 2023-03-14 13:32:47 -05:00
userblock.py fix MovedIn20Warning 2023-03-14 13:32:47 -05:00
usernotes.py fix MovedIn20Warning 2023-03-14 13:32:47 -05:00
views.py fix MovedIn20Warning 2023-03-14 13:32:47 -05:00
volunteer_janitor.py fix MovedIn20Warning 2023-03-14 13:32:47 -05:00
votes.py fix MovedIn20Warning 2023-03-14 13:32:47 -05:00