aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/account/user-video-history.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-11 15:38:53 +0200
committerChocobozzz <me@florianbigard.com>2019-04-11 15:38:53 +0200
commit8f0bc73d7d5f4c88cbc5588a0ece12b3855c8f98 (patch)
treee04f1da52f9377cf6ce820425c0de6e57ab57fc6 /server/models/account/user-video-history.ts
parent76062d9f96e06a23a2efc8a727ea9c5394d21466 (diff)
downloadPeerTube-8f0bc73d7d5f4c88cbc5588a0ece12b3855c8f98.tar.gz
PeerTube-8f0bc73d7d5f4c88cbc5588a0ece12b3855c8f98.tar.zst
PeerTube-8f0bc73d7d5f4c88cbc5588a0ece12b3855c8f98.zip
Add ability to limit videos history size
Diffstat (limited to 'server/models/account/user-video-history.ts')
-rw-r--r--server/models/account/user-video-history.ts14
1 files changed, 13 insertions, 1 deletions
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<UserVideoHistoryModel> {
67 }) 67 })
68 } 68 }
69 69
70 static removeHistoryBefore (user: UserModel, beforeDate: string, t: Transaction) { 70 static removeUserHistoryBefore (user: UserModel, beforeDate: string, t: Transaction) {
71 const query: DestroyOptions = { 71 const query: DestroyOptions = {
72 where: { 72 where: {
73 userId: user.id 73 userId: user.id
@@ -83,4 +83,16 @@ export class UserVideoHistoryModel extends Model<UserVideoHistoryModel> {
83 83
84 return UserVideoHistoryModel.destroy(query) 84 return UserVideoHistoryModel.destroy(query)
85 } 85 }
86
87 static removeOldHistory (beforeDate: string) {
88 const query: DestroyOptions = {
89 where: {
90 updatedAt: {
91 [Op.lt]: beforeDate
92 }
93 }
94 }
95
96 return UserVideoHistoryModel.destroy(query)
97 }
86} 98}