]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/account/user-video-history.ts
Add user adminFlags
[github/Chocobozzz/PeerTube.git] / server / models / account / user-video-history.ts
index 15cb399c952bc909305e331baf8cece53bccd45d..49d2def8158386a64aa17c2b1b07cbdce2f78253 100644 (file)
@@ -67,7 +67,7 @@ export class UserVideoHistoryModel extends Model<UserVideoHistoryModel> {
     })
   }
 
-  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<UserVideoHistoryModel> {
 
     return UserVideoHistoryModel.destroy(query)
   }
+
+  static removeOldHistory (beforeDate: string) {
+    const query: DestroyOptions = {
+      where: {
+        updatedAt: {
+          [Op.lt]: beforeDate
+        }
+      }
+    }
+
+    return UserVideoHistoryModel.destroy(query)
+  }
 }