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:
parent
6f1391aead
commit
8c9f9dc42f
2 changed files with 112 additions and 9 deletions
|
@ -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>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue