aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-11 17:33:36 +0200
committerChocobozzz <me@florianbigard.com>2019-04-12 08:31:06 +0200
commitcda03765fe366f028897e9b02dd4a0a19af3c935 (patch)
tree4d30303d76f8fd171195a51b1f737a0067987d6c /server/models
parent7b293f28686319242958dff7315cdd8ad74fc15e (diff)
downloadPeerTube-cda03765fe366f028897e9b02dd4a0a19af3c935.tar.gz
PeerTube-cda03765fe366f028897e9b02dd4a0a19af3c935.tar.zst
PeerTube-cda03765fe366f028897e9b02dd4a0a19af3c935.zip
Add ability to delete old remote views
Diffstat (limited to 'server/models')
-rw-r--r--server/models/video/video-views.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/server/models/video/video-views.ts b/server/models/video/video-views.ts
index fde5f7056..6071e8c22 100644
--- a/server/models/video/video-views.ts
+++ b/server/models/video/video-views.ts
@@ -41,4 +41,18 @@ export class VideoViewModel extends Model<VideoViewModel> {
41 }) 41 })
42 Video: VideoModel 42 Video: VideoModel
43 43
44 static removeOldRemoteViewsHistory (beforeDate: string) {
45 const query = {
46 where: {
47 startDate: {
48 [Sequelize.Op.lt]: beforeDate
49 },
50 videoId: {
51 [Sequelize.Op.in]: Sequelize.literal('(SELECT "id" FROM "video" WHERE "remote" IS TRUE)')
52 }
53 }
54 }
55
56 return VideoViewModel.destroy(query)
57 }
44} 58}