-
Notifications
You must be signed in to change notification settings - Fork 19
Generate a materialized view for gameRatingsSandbox0
#270
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
Merged
Conversation
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
|
Is Perhaps both the view and the cron jobs should be documented somewhere. |
5fd9299 to
307dc87
Compare
|
I added more comments about |
307dc87 to
3d3989f
Compare
9035f54 to
d510edb
Compare
The `gameRatingsSandbox0` view is used all over the site, but it's a pure view, built from several nested queries that don't optimize well. In this commit, we're creating a `gameRatingsSandbox0_mv` materialized-view table, generated from the original `gameRatingsSandbox0` view, updated by triggers on the `reviews` table.
The `gameRatingsSandbox0` view automatically updates to include reviews whose embargo dates have passed, but we need to make an update to the `reviews` table when a review's embargo date passes in order to update the `gameRatingsSandbox0_mv` materialized view. Here, we're adding an `embargopastdate` column to `reviews`, which we update when the embargo date has actually passed. That update will refresh the materialized view. And then we're adding an URL that can be managed by a cron job to update `embargopastdate` for any/all reviews that just passed their embargo date.
When a user enters/leaves the sandbox, their reviews will need to be updated in the `gameRatingsSandbox0_mv` materialized view. This code is kinda inefficient, regenerating the entire materialized view from scratch whenever any user is added/removed from the sandbox, but as of today that still only takes a second or so, and users don't get sandboxed or unsandboxed very often.
"Banning" means clicking the "ban" button in `adminops`, which sets `acctstatus` to `B` (preventing login) and sets `sandbox` to 1. Each time we update users.sandbox, we have to regenerate `gameRatingsSandbox0_mv`, to exclude sandboxed reviews.
d510edb to
90ae5a7
Compare
dfabulich
added a commit
that referenced
this pull request
Feb 3, 2025
The code was doing a `left join` (aka a `left outer join`) to `gameRatingsSandbox0_mv` unless `$browse` mode is enabled and you're using one of the specified sort orders, in which case it does a simple `join` (an `inner join`). I wrote this code in PR #270, specifically in 3bd2c7a. But… why did I write that? Why didn't I just do an inner join in all cases? To be quite honest, I can't remember. I bet the issue was that `gameRatingsSandbox0_mv` didn't have exactly as many rows as the `games` table. (And I bet I was misusing `$browse` … it probably should have been `!$term`.) I believe that `gameRatingsSandbox0_mv` will always have a row for every game in the games table, now that we've merged #1266, and so it should be safe to do an inner join in all cases.
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.
Now we'll use
gameRatingsSandbox0_mvfor pretty much all purposes.Fixes #478 and fixes #472