From 8f0bc73d7d5f4c88cbc5588a0ece12b3855c8f98 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 11 Apr 2019 15:38:53 +0200 Subject: Add ability to limit videos history size --- server/models/account/user-video-history.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'server/models') diff --git a/server/models/account/user-video-history.ts b/server/models/account/user-video-history.ts index 15cb399c9..49d2def81 100644 --- a/server/models/account/user-video-history.ts +++ b/server/models/account/user-video-history.ts @@ -67,7 +67,7 @@ export class UserVideoHistoryModel extends Model { }) } - static removeHistoryBefore (user: UserModel, beforeDate: string, t: Transaction) { + static removeUserHistoryBefore (user: UserModel, beforeDate: string, t: Transaction) { const query: DestroyOptions = { where: { userId: user.id @@ -83,4 +83,16 @@ export class UserVideoHistoryModel extends Model { return UserVideoHistoryModel.destroy(query) } + + static removeOldHistory (beforeDate: string) { + const query: DestroyOptions = { + where: { + updatedAt: { + [Op.lt]: beforeDate + } + } + } + + return UserVideoHistoryModel.destroy(query) + } } -- cgit v1.2.3