-
-
Notifications
You must be signed in to change notification settings - Fork 408
feat(db): Refactor dbRefresh and add dbUpdate #810
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
Conversation
…hat have changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 9 out of 13 changed files in this pull request and generated 1 comment.
Files not reviewed (4)
- .nvmrc: Language not supported
- Dockerfile: Language not supported
- package.json: Language not supported
- scripts/tsconfig.json: Language not supported
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…database into bagelbits.dbRefresh-refactor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 10 out of 14 changed files in this pull request and generated no comments.
Files not reviewed (4)
- .nvmrc: Language not supported
- Dockerfile: Language not supported
- package.json: Language not supported
- scripts/tsconfig.json: Language not supported
Comments suppressed due to low confidence (2)
scripts/update/gitUtils.ts:24
- This code assumes that the status code is always a single character. If Git returns a multi-character status in some cases, this could lead to incorrect status parsing. Consider using the entire status string or validating the expected format.
const status = parts[0][0] as ChangedFile['status'];
scripts/dbRefresh.ts:57
- Although the code later checks if the parsed data is an array, adding explicit validation immediately after parsing the JSON could help catch unexpected data formats earlier and improve error clarity.
data = JSON.parse(readFileSync(filepath, 'utf8'));
|
🎉 This PR is included in version 3.13.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
What does this do?
This PR significantly refactors and enhances the database update process, focusing on efficiency, maintainability, and reliability.
Key Changes & Improvements:
Introduces Incremental Database Updates (
dbUpdate.ts):dbUpdate.tsscript that analyzes Git history (HEAD~1..HEAD) to find changed JSON files (src/**/*.json).upsertordeleteoperations on individual records within the corresponding MongoDB collections.2014-collections).Refactors Shared Logic & Improves
dbRefresh.ts:dbUtils.tsfile to house shared utility functions (e.g., deriving collection/index names from file paths), reducing duplication (DRY).dbRefresh.tsscript to:dbUtils.tsfor consistency.mongodbdriver instead of shelling out tomongoimport.Optimizes CI/CD Pipeline (
ci.yml):deployjob now runs the newdbUpdate.tsscript instead of the fulldbRefresh.ts, resulting in significantly faster deployments that only apply necessary changes.manual-db-refresh.yml) as a "break glass" option to run the fulldbRefresh.tsif needed.npm cifor faster/more reliable installs and enablesnpmcaching.Standardizes Environment & Configuration:
package.json, andDockerfileto consistently use Node.js v22.x (LTS)..nvmrcfile to enforce the Node version locally.tsconfig.jsonconfiguration.How was it tested?
docker-composeof API and DB1. Noted
updated_atfield for bothexport MONGODB_URI=mongodb://localhost:27017/5e-database npm run db:updatearmor_classvalue in Acolyte and made a git commitexport MONGODB_URI=mongodb://localhost:27017/5e-database npm run db:updateupdated_attimestamp was changed for only AcolyteIs there a Github issue this is resolving?
No. But I've been wanting to do this for so long.
Here's a fun image for your troubles