Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creates and joins against a view used to get the rank of a replay. #508

Merged
merged 1 commit into from
Aug 24, 2024

Conversation

n-rook
Copy link
Owner

@n-rook n-rook commented Aug 19, 2024

See #507. This new function is not yet used, but I figure we can replace the existing annotate_with_rank() with it. The new approach allows for us to more easily get ranks in situations where the required data isn't returned in the query, which is nice. It's a bit slower, so we may need to convert this to a "materialized view", but I think it's still acceptable right now, especially with the new index.

See #507. This new function is not yet used, but I figure we can replace
the existing annotate_with_rank() with it. The new approach allows for us to
more easily get ranks in situations where the required data isn't returned
in the query, which is nice. It's a bit slower, so we may need to
convert this to a "materialized view", but I think it's still acceptable
right now, especially with the new index.
Copy link
Collaborator

@jgdhs27 jgdhs27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so much better! I didn't know you could just write views like this.

Btw, how did you define the view? Did you just write the SQL to create it in 0041_replay_rank_view.py?

@n-rook
Copy link
Owner Author

n-rook commented Aug 24, 2024

Yeah, I wrote the 0041 migration file myself. Django doesn't really support views in any meaningful sense, but a view can be queried the same way as a table, so if we make a view ourselves (and tell Django not to try to create it as a table; that's what the "managed = False" is for) we can access it through Django similarly to how we would access a table.

It took a bunch of Googling to figure out how people deal with this situation!

@n-rook n-rook merged commit da51b82 into main Aug 24, 2024
4 checks passed
@n-rook n-rook deleted the nrook/new-rank branch August 24, 2024 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants