mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-09 04:02:40 -05:00
Delete old room links routine
This commit is contained in:
parent
8b921c2728
commit
f54cb285ce
|
|
@ -45,3 +45,14 @@ export function refreshTimestamp(userId: number) {
|
|||
.where("userId", "=", userId)
|
||||
.execute();
|
||||
}
|
||||
|
||||
export function deleteOld() {
|
||||
return db
|
||||
.deleteFrom("RoomLink")
|
||||
.where(
|
||||
"refreshedAt",
|
||||
"<",
|
||||
dateToDatabaseTimestamp(sub(new Date(), { hours: 2 })),
|
||||
)
|
||||
.executeTakeFirst();
|
||||
}
|
||||
|
|
|
|||
11
app/routines/deleteOldRoomLinks.ts
Normal file
11
app/routines/deleteOldRoomLinks.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import * as RoomLinkRepository from "../features/chat/RoomLinkRepository.server";
|
||||
import { logger } from "../utils/logger";
|
||||
import { Routine } from "./routine.server";
|
||||
|
||||
export const DeleteOldRoomLinksRoutine = new Routine({
|
||||
name: "DeleteOldRoomLinks",
|
||||
func: async () => {
|
||||
const { numDeletedRows } = await RoomLinkRepository.deleteOld();
|
||||
logger.info(`Deleted ${numDeletedRows} old room links`);
|
||||
},
|
||||
});
|
||||
|
|
@ -2,6 +2,7 @@ import { CloseExpiredCommissionsRoutine } from "./closeExpiredCommissions";
|
|||
import { CloseExpiredContinueVotesRoutine } from "./closeExpiredContinueVotes";
|
||||
import { DeleteObsoleteMatchVodsRoutine } from "./deleteObsoleteMatchVods";
|
||||
import { DeleteOldNotificationsRoutine } from "./deleteOldNotifications";
|
||||
import { DeleteOldRoomLinksRoutine } from "./deleteOldRoomLinks";
|
||||
import { DeleteOrphanArtTagsRoutine } from "./deleteOrphanArtTags";
|
||||
import { NotifyCheckInStartRoutine } from "./notifyCheckInStart";
|
||||
import { NotifyPlusServerVotingRoutine } from "./notifyPlusServerVoting";
|
||||
|
|
@ -28,6 +29,7 @@ export const everyHourAt30 = [
|
|||
SetOldGroupsAsInactiveRoutine,
|
||||
UpdatePatreonDataRoutine,
|
||||
CloseExpiredContinueVotesRoutine,
|
||||
DeleteOldRoomLinksRoutine,
|
||||
];
|
||||
|
||||
/** List of Routines that should occur daily */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user