-
-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔨 store grapher configs in R2 when edited in the admin (#3827)
This PR does 2 things at the high level: it stores grapher configs in R2 when they are edited in the admin, and it adds a tool for syncing the content of the `chart_configs ` table into R2 (adding/updating missing ones and deleting superfluous ones). Charts are stored in R2 in two folders for now: one that is used for all configs addressed by chart UUID, and one addressed by slug for only published standalone charts. This PR adds a hash of the full config in the `chart_configs` table. I started out using a SHA-1 and was happy that R2 supports those in addition to MD5, only to discover later on when I wrote the sync tool that the S3 API list operation has no support for hashes other than MD5. Since the main point of the hash is facilitate efficient comparison between set of configs in the DB and those in R2 I then rewrote the hash to be md5. The hash is stored in base64 encoding since this is also what is used and returned in most api calls (the only exception is the ETAG where a hex serialization in double quotes is used 🤷) We already have a key configured for interacting with R2 so I renamed the settings related to this key to have a generic (non-image specific) name. To test this: - set the R2_ACCESS_KEY_ID and R2_SECRET_ACCESS_KEY to a personal CF R2 token that you generate. If you already did this previously for images (i.e. if your .env file already has IMAGE_HOSTING_R2_ACCESS_KEY_ID) then rename these two keys AND make sure that your personal key has access to the `owid-grapher-configs-staging` bucket (CF dashboard -> R2 -> manage api tokens in the top right) - set GRAPHER_CONFIG_R2_BUCKET to `owid-grapher-configs-staging` and GRAPHER_CONFIG_R2_BUCKET_PATH to `devs/YOURNAME` Then when you interact with the admin and save graphers, you should see these charts show up as json files in the R2 bucket in the `owid-grapher-configs-staging` bucket.
- Loading branch information
Showing
19 changed files
with
747 additions
and
60 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,3 +43,4 @@ dist/ | |
.nx/workspace-data | ||
.dev.vars | ||
**/tsup.config.bundled*.mjs | ||
cfstorage/ |
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
Oops, something went wrong.