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

Centralize archive deletion loop; stagger different centralized loops slightly

This commit is contained in:
Dragory 2021-09-25 21:53:48 +03:00
parent 2d84a02d48
commit 617a4ea7fc
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
4 changed files with 44 additions and 18 deletions

View file

@ -0,0 +1,21 @@
import { getRepository, Repository } from "typeorm";
import { ArchiveEntry } from "./entities/ArchiveEntry";
import { BaseRepository } from "./BaseRepository";
export class Archives extends BaseRepository {
protected archives: Repository<ArchiveEntry>;
constructor() {
super();
this.archives = getRepository(ArchiveEntry);
}
public deleteExpiredArchives() {
this.archives
.createQueryBuilder()
.andWhere("expires_at IS NOT NULL")
.andWhere("expires_at <= NOW()")
.delete()
.execute();
}
}