3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 04:25:01 +00:00

Add config retention period / cleanup

This commit is contained in:
Dragory 2020-06-02 00:47:37 +03:00
parent 6f1391aead
commit 8c9f9dc42f
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
2 changed files with 112 additions and 9 deletions

View file

@ -1,15 +1,22 @@
import { Config } from "./entities/Config";
import {
getConnection,
getRepository,
Repository,
Transaction,
TransactionManager,
TransactionRepository,
} from "typeorm";
import { BaseGuildRepository } from "./BaseGuildRepository";
import { getRepository, Repository } from "typeorm";
import { connection } from "./db";
import { BaseRepository } from "./BaseRepository";
import { isAPI } from "../globals";
import { HOURS, SECONDS } from "../utils";
import { cleanupConfigs } from "./cleanup/configs";
if (isAPI()) {
const CLEANUP_INTERVAL = 1 * HOURS;
async function cleanup() {
await cleanupConfigs();
setTimeout(cleanup, CLEANUP_INTERVAL);
}
// Start first cleanup 30 seconds after startup
setTimeout(cleanup, 30 * SECONDS);
}
export class Configs extends BaseRepository {
private configs: Repository<Config>;