mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-22 01:36:29 -05:00
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>
This commit is contained in:
parent
4884292b68
commit
41b13e71b6
1 changed files with 13 additions and 6 deletions
19
bin/cleanup
19
bin/cleanup
|
@ -9,8 +9,10 @@ async function cleanup() {
|
||||||
await models.Note.findAll({
|
await models.Note.findAll({
|
||||||
include: [{
|
include: [{
|
||||||
model: models.User,
|
model: models.User,
|
||||||
as: 'owner'
|
as: 'owner',
|
||||||
}]
|
attributes: ['id']
|
||||||
|
}],
|
||||||
|
attributes: ['id', 'ownerId']
|
||||||
}).then(async function(notes) {
|
}).then(async function(notes) {
|
||||||
for(let i =0, noteCount = notes.length; i< noteCount; i++) {
|
for(let i =0, noteCount = notes.length; i< noteCount; i++) {
|
||||||
const item = notes[i]
|
const item = notes[i]
|
||||||
|
@ -36,8 +38,10 @@ async function cleanup() {
|
||||||
await models.Author.findAll({
|
await models.Author.findAll({
|
||||||
include: [{
|
include: [{
|
||||||
model: models.User,
|
model: models.User,
|
||||||
as: 'user'
|
as: 'user',
|
||||||
}]
|
attributes: ['id']
|
||||||
|
}],
|
||||||
|
attributes: ['id', 'userId']
|
||||||
}).then(async function(authors) {
|
}).then(async function(authors) {
|
||||||
for(let i =0, authorCount = authors.length; i< authorCount; i++) {
|
for(let i =0, authorCount = authors.length; i< authorCount; i++) {
|
||||||
const item = authors[i]
|
const item = authors[i]
|
||||||
|
@ -50,11 +54,14 @@ async function cleanup() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
await models.Revision.findAll({
|
await models.Revision.findAll({
|
||||||
include: [{
|
include: [{
|
||||||
model: models.Note,
|
model: models.Note,
|
||||||
as: 'note'
|
as: 'note',
|
||||||
}]
|
attributes: ['id']
|
||||||
|
}],
|
||||||
|
attributes: ['id', 'noteId']
|
||||||
}).then(async function(revisions) {
|
}).then(async function(revisions) {
|
||||||
for(let i =0, revisionCount = revisions.length; i< revisionCount; i++) {
|
for(let i =0, revisionCount = revisions.length; i< revisionCount; i++) {
|
||||||
const item = revisions[i]
|
const item = revisions[i]
|
||||||
|
|
Loading…
Reference in a new issue