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
Generate a materialized view for gameRatingsSandbox0
#270
Merged
Conversation
This file contains 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. |
dfabulich
force-pushed
the
game-ratings-materialized-view
branch
from
January 2, 2024 09:34
5fd9299
to
307dc87
Compare
I added more comments about
|
dfabulich
force-pushed
the
game-ratings-materialized-view
branch
from
January 2, 2024 20:11
307dc87
to
3d3989f
Compare
dfabulich
force-pushed
the
game-ratings-materialized-view
branch
from
January 3, 2024 12:15
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.
dfabulich
force-pushed
the
game-ratings-materialized-view
branch
from
January 3, 2024 12:17
d510edb
to
90ae5a7
Compare
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_mv
for pretty much all purposes.Fixes iftechfoundation/ifdb-suggestion-tracker#401 and fixes iftechfoundation/ifdb-suggestion-tracker#407