aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-02-21 21:35:59 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-02-26 20:01:26 +0100
commit9e167724f7e933f41d9ea2e1c31772bf4c560a28 (patch)
tree093cb7c1b088f35aaf847f859a313a121c8cd233 /server/models/video.js
parent0150b17e51df3e9fad8a59133d828c68f8ba672b (diff)
downloadPeerTube-9e167724f7e933f41d9ea2e1c31772bf4c560a28.tar.gz
PeerTube-9e167724f7e933f41d9ea2e1c31772bf4c560a28.tar.zst
PeerTube-9e167724f7e933f41d9ea2e1c31772bf4c560a28.zip
Server: make a basic "quick and dirty update" for videos
This system will be useful to to update some int video attributes (likes, dislikes, views...) The classic system is not used because we need some optimization for scaling
Diffstat (limited to 'server/models/video.js')
-rw-r--r--server/models/video.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/server/models/video.js b/server/models/video.js
index d0fd61eb4..daa273845 100644
--- a/server/models/video.js
+++ b/server/models/video.js
@@ -80,6 +80,15 @@ module.exports = function (sequelize, DataTypes) {
80 if (res === false) throw new Error('Video duration is not valid.') 80 if (res === false) throw new Error('Video duration is not valid.')
81 } 81 }
82 } 82 }
83 },
84 views: {
85 type: DataTypes.INTEGER,
86 allowNull: false,
87 defaultValue: 0,
88 validate: {
89 min: 0,
90 isInt: true
91 }
83 } 92 }
84 }, 93 },
85 { 94 {
@@ -101,6 +110,9 @@ module.exports = function (sequelize, DataTypes) {
101 }, 110 },
102 { 111 {
103 fields: [ 'infoHash' ] 112 fields: [ 'infoHash' ]
113 },
114 {
115 fields: [ 'views' ]
104 } 116 }
105 ], 117 ],
106 classMethods: { 118 classMethods: {
@@ -336,6 +348,7 @@ function toFormatedJSON () {
336 magnetUri: this.generateMagnetUri(), 348 magnetUri: this.generateMagnetUri(),
337 author: this.Author.name, 349 author: this.Author.name,
338 duration: this.duration, 350 duration: this.duration,
351 views: this.views,
339 tags: map(this.Tags, 'name'), 352 tags: map(this.Tags, 'name'),
340 thumbnailPath: pathUtils.join(constants.STATIC_PATHS.THUMBNAILS, this.getThumbnailName()), 353 thumbnailPath: pathUtils.join(constants.STATIC_PATHS.THUMBNAILS, this.getThumbnailName()),
341 createdAt: this.createdAt, 354 createdAt: this.createdAt,