mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
perf: smaller DELETE chunks for saved messages, sleep 1s between batches
This commit is contained in:
parent
55a39e0758
commit
d80e642cba
1 changed files with 3 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
import moment from "moment-timezone";
|
||||
import { getRepository, In } from "typeorm";
|
||||
import { DAYS, DBDateFormat, MINUTES } from "../../utils";
|
||||
import { DAYS, DBDateFormat, MINUTES, SECONDS, sleep } from "../../utils";
|
||||
import { connection } from "../db";
|
||||
import { SavedMessage } from "../entities/SavedMessage";
|
||||
|
||||
|
@ -11,7 +11,7 @@ import { SavedMessage } from "../entities/SavedMessage";
|
|||
const RETENTION_PERIOD = 1 * DAYS;
|
||||
const BOT_MESSAGE_RETENTION_PERIOD = 30 * MINUTES;
|
||||
const DELETED_MESSAGE_RETENTION_PERIOD = 5 * MINUTES;
|
||||
const CLEAN_PER_LOOP = 200;
|
||||
const CLEAN_PER_LOOP = 100;
|
||||
|
||||
export async function cleanupMessages(): Promise<number> {
|
||||
let cleaned = 0;
|
||||
|
@ -79,6 +79,7 @@ export async function cleanupMessages(): Promise<number> {
|
|||
await messagesRepository.delete({
|
||||
id: In(ids),
|
||||
});
|
||||
await sleep(1 * SECONDS);
|
||||
}
|
||||
|
||||
cleaned += ids.length;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue