mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-07 19:17:19 +00:00
feat: upgrade to TypeORM 0.3
This commit is contained in:
parent
8cee4ec1e4
commit
761ff27771
57 changed files with 412 additions and 325 deletions
|
@ -1,7 +1,7 @@
|
|||
import moment from "moment-timezone";
|
||||
import { getRepository, In } from "typeorm";
|
||||
import { In } from "typeorm";
|
||||
import { DAYS, DBDateFormat, MINUTES, SECONDS, sleep } from "../../utils";
|
||||
import { connection } from "../db";
|
||||
import { dataSource } from "../dataSource";
|
||||
import { SavedMessage } from "../entities/SavedMessage";
|
||||
|
||||
/**
|
||||
|
@ -16,7 +16,7 @@ const CLEAN_PER_LOOP = 100;
|
|||
export async function cleanupMessages(): Promise<number> {
|
||||
let cleaned = 0;
|
||||
|
||||
const messagesRepository = getRepository(SavedMessage);
|
||||
const messagesRepository = dataSource.getRepository(SavedMessage);
|
||||
|
||||
const deletedAtThreshold = moment.utc().subtract(DELETED_MESSAGE_RETENTION_PERIOD, "ms").format(DBDateFormat);
|
||||
const postedAtThreshold = moment.utc().subtract(RETENTION_PERIOD, "ms").format(DBDateFormat);
|
||||
|
@ -27,7 +27,7 @@ export async function cleanupMessages(): Promise<number> {
|
|||
// when a message was being inserted at the same time
|
||||
let ids: string[];
|
||||
do {
|
||||
const deletedMessageRows = await connection.query(
|
||||
const deletedMessageRows = await dataSource.query(
|
||||
`
|
||||
SELECT id
|
||||
FROM messages
|
||||
|
@ -40,7 +40,7 @@ export async function cleanupMessages(): Promise<number> {
|
|||
[deletedAtThreshold],
|
||||
);
|
||||
|
||||
const oldPostedRows = await connection.query(
|
||||
const oldPostedRows = await dataSource.query(
|
||||
`
|
||||
SELECT id
|
||||
FROM messages
|
||||
|
@ -53,7 +53,7 @@ export async function cleanupMessages(): Promise<number> {
|
|||
[postedAtThreshold],
|
||||
);
|
||||
|
||||
const oldBotPostedRows = await connection.query(
|
||||
const oldBotPostedRows = await dataSource.query(
|
||||
`
|
||||
SELECT id
|
||||
FROM messages
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue