diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-02-21 21:35:59 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-02-26 20:01:26 +0100 |
commit | 9e167724f7e933f41d9ea2e1c31772bf4c560a28 (patch) | |
tree | 093cb7c1b088f35aaf847f859a313a121c8cd233 /server/controllers/api/videos.js | |
parent | 0150b17e51df3e9fad8a59133d828c68f8ba672b (diff) | |
download | PeerTube-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/controllers/api/videos.js')
-rw-r--r-- | server/controllers/api/videos.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/server/controllers/api/videos.js b/server/controllers/api/videos.js index c936105e7..9f4bbb7b7 100644 --- a/server/controllers/api/videos.js +++ b/server/controllers/api/videos.js | |||
@@ -320,6 +320,22 @@ function updateVideo (req, res, finalCallback) { | |||
320 | 320 | ||
321 | function getVideo (req, res, next) { | 321 | function getVideo (req, res, next) { |
322 | const videoInstance = res.locals.video | 322 | const videoInstance = res.locals.video |
323 | |||
324 | if (videoInstance.isOwned()) { | ||
325 | // The increment is done directly in the database, not using the instance value | ||
326 | videoInstance.increment('views').asCallback(function (err) { | ||
327 | if (err) { | ||
328 | logger.error('Cannot add view to video %d.', videoInstance.id) | ||
329 | return | ||
330 | } | ||
331 | |||
332 | // FIXME: make a real view system | ||
333 | // For example, only add a view when a user watch a video during 30s etc | ||
334 | friends.quickAndDirtyUpdateVideoToFriends(videoInstance.id, constants.REQUEST_VIDEO_QADU_TYPES.VIEWS) | ||
335 | }) | ||
336 | } | ||
337 | |||
338 | // Do not wait the view system | ||
323 | res.json(videoInstance.toFormatedJSON()) | 339 | res.json(videoInstance.toFormatedJSON()) |
324 | } | 340 | } |
325 | 341 | ||