The User model class method user_awards previously made one query
per type of award. This has been replaced with a new query that
retrieves all owned award quantities at once using GROUP BY.
The user routes upvoters, downvoters, upvoting, and downvoting
now exclude self-votes from the summary totals.
Also, the diff touches a number of other lines where the local
variable `id` was renamed to `uid` for semantic clarity.
h/t to @official-techsupport for finding and help fixing this bug.
When given certain pathological input, `sanitize` would time out
(notably only on posts, rather than comments, perhaps due to the
longer maximum length of input). For example, using as input the
result of:
with open("test.txt", "w") as f:
for i in range(26):
f.write(f":{chr(ord('a') + i)}: ")
f.write('x' * 20_000)
We believe this to be because of some combination of the greedy
quantifiers and the negative lookahead before the match. The regex
was rewritten to (in theory) have much more linear performance.
The JSON API endpoints that return comments, most notably `/comments`
returned 500s and created a stack trace with:
TypeError: Object of type method is not JSON serializable
Further debugging revealed this was because json.encoder was being
given a <bound method lazy.<locals>.wrapper of <Comment(id=123)>> to
serialize.
The introduction of the bug was traced to 8ecb4582d0 where it was
discovered that the (seemingly inadvertent) removal of the @property
decorator on classes/comment.py:parent_fullname was the root cause.
In light of the fact that parent_fullname was unrelated to the changes
intended in 8ecb4582d0 and that no other refactoring around
parent_fullname was done, it was restored to being a @property rather
than its callers modified to invoke it as a method.