aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-views.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-29 16:26:25 +0200
committerChocobozzz <me@florianbigard.com>2018-08-30 15:03:18 +0200
commit6b6168606bc86430f6b7821c9d5f1c80d0425ebf (patch)
tree9aea6cf0875c9fee30c373eb4924b12d47d1e23c /server/models/video/video-views.ts
parent2d9fea161fd4fc73994fc77951bafdccdc2071fd (diff)
downloadPeerTube-6b6168606bc86430f6b7821c9d5f1c80d0425ebf.tar.gz
PeerTube-6b6168606bc86430f6b7821c9d5f1c80d0425ebf.tar.zst
PeerTube-6b6168606bc86430f6b7821c9d5f1c80d0425ebf.zip
Bufferize videos views in redis
Diffstat (limited to 'server/models/video/video-views.ts')
-rw-r--r--server/models/video/video-views.ts41
1 files changed, 41 insertions, 0 deletions
diff --git a/server/models/video/video-views.ts b/server/models/video/video-views.ts
new file mode 100644
index 000000000..90ce671fd
--- /dev/null
+++ b/server/models/video/video-views.ts
@@ -0,0 +1,41 @@
1import { AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, Model, Table } from 'sequelize-typescript'
2import { VideoModel } from './video'
3import * as Sequelize from 'sequelize'
4
5@Table({
6 tableName: 'videoView',
7 indexes: [
8 {
9 fields: [ 'videoId' ]
10 }
11 ]
12})
13export class VideoViewModel extends Model<VideoViewModel> {
14 @CreatedAt
15 createdAt: Date
16
17 @AllowNull(false)
18 @Column(Sequelize.DATE)
19 startDate: Date
20
21 @AllowNull(false)
22 @Column(Sequelize.DATE)
23 endDate: Date
24
25 @AllowNull(false)
26 @Column
27 views: number
28
29 @ForeignKey(() => VideoModel)
30 @Column
31 videoId: number
32
33 @BelongsTo(() => VideoModel, {
34 foreignKey: {
35 allowNull: false
36 },
37 onDelete: 'CASCADE'
38 })
39 Video: VideoModel
40
41}