diff options
author | Sheogorath | 2020-03-21 19:27:02 +0100 |
---|---|---|
committer | Sheogorath | 2020-03-21 19:30:44 +0100 |
commit | 41b13e71b6b1d499238c04b15d65e3bd76442f1d (patch) | |
tree | 2321759fcf77eeb3bf90167ad462b51231a906b2 /bin/cleanup | |
parent | 4884292b68c7b5bcf086b6322d8c74f542fc96dc (diff) |
Reduce requested arguments on cleanup
In order to prevent OOM situations due to large databases, this patch
should reduce the amount of data requested from the database
drastically.
Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
Diffstat (limited to '')
-rwxr-xr-x | bin/cleanup | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/bin/cleanup b/bin/cleanup index a25a8320..6ccbb07d 100755 --- a/bin/cleanup +++ b/bin/cleanup @@ -9,8 +9,10 @@ async function cleanup() { await models.Note.findAll({ include: [{ model: models.User, - as: 'owner' - }] + as: 'owner', + attributes: ['id'] + }], + attributes: ['id', 'ownerId'] }).then(async function(notes) { for(let i =0, noteCount = notes.length; i< noteCount; i++) { const item = notes[i] @@ -36,8 +38,10 @@ async function cleanup() { await models.Author.findAll({ include: [{ model: models.User, - as: 'user' - }] + as: 'user', + attributes: ['id'] + }], + attributes: ['id', 'userId'] }).then(async function(authors) { for(let i =0, authorCount = authors.length; i< authorCount; i++) { const item = authors[i] @@ -50,11 +54,14 @@ async function cleanup() { } } }) + await models.Revision.findAll({ include: [{ model: models.Note, - as: 'note' - }] + as: 'note', + attributes: ['id'] + }], + attributes: ['id', 'noteId'] }).then(async function(revisions) { for(let i =0, revisionCount = revisions.length; i< revisionCount; i++) { const item = revisions[i] |