Open
Conversation
AdmiralGT
requested changes
Sep 28, 2025
scripts/views.py
Outdated
| character_count[type.value] = Counter() | ||
| num_count[type.value] = Counter() | ||
|
|
||
| character_counts = queries.get_all_script_character_counts() |
Owner
There was a problem hiding this comment.
issue I believe you've lost all of the prior queryset filtering that has occurred with the change. The statistics page can also have parameterised filtering (albeit it's not the most common usage).
scripts/queries.py
Outdated
| cursor.execute(""" | ||
| SELECT character_type->>'id' AS character, COUNT(1) AS count | ||
| FROM "scripts_scriptversion" | ||
| CROSS JOIN LATERAL jsonb_array_elements(content) character_type |
Owner
There was a problem hiding this comment.
nitpick I'm really not keen on the use of "character_type" here as a name as that is a specific clocktower term and this isn't related to that terminology.
suggestion I'd use character_instance rather than _type as the representation.
Contributor
Author
|
Unfortunately I don’t know Django at all, I did try to research but I couldn't see a way to achieve this query in the ORM syntax so I’ve just opted to embed the queryset SQL as a subquery here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#586 sped up stats load but it’s still very slow. Without real data I’ve not been able to reproduce the load time locally but I think this change should help.