From 41b13e71b6b1d499238c04b15d65e3bd76442f1d Mon Sep 17 00:00:00 2001 From: Sheogorath Date: Sat, 21 Mar 2020 19:27:02 +0100 Subject: 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 --- bin/cleanup | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'bin/cleanup') 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] -- cgit v1.2.3