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/initializers | |
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/initializers')
-rw-r--r-- | server/initializers/constants.js | 20 | ||||
-rw-r--r-- | server/initializers/migrations/0015-video-views.js | 19 |
2 files changed, 36 insertions, 3 deletions
diff --git a/server/initializers/constants.js b/server/initializers/constants.js index 821580893..668bfe56c 100644 --- a/server/initializers/constants.js +++ b/server/initializers/constants.js | |||
@@ -5,7 +5,7 @@ const path = require('path') | |||
5 | 5 | ||
6 | // --------------------------------------------------------------------------- | 6 | // --------------------------------------------------------------------------- |
7 | 7 | ||
8 | const LAST_MIGRATION_VERSION = 10 | 8 | const LAST_MIGRATION_VERSION = 15 |
9 | 9 | ||
10 | // --------------------------------------------------------------------------- | 10 | // --------------------------------------------------------------------------- |
11 | 11 | ||
@@ -24,7 +24,7 @@ const SEARCHABLE_COLUMNS = { | |||
24 | const SORTABLE_COLUMNS = { | 24 | const SORTABLE_COLUMNS = { |
25 | USERS: [ 'id', '-id', 'username', '-username', 'createdAt', '-createdAt' ], | 25 | USERS: [ 'id', '-id', 'username', '-username', 'createdAt', '-createdAt' ], |
26 | VIDEO_ABUSES: [ 'id', '-id', 'createdAt', '-createdAt' ], | 26 | VIDEO_ABUSES: [ 'id', '-id', 'createdAt', '-createdAt' ], |
27 | VIDEOS: [ 'name', '-name', 'duration', '-duration', 'createdAt', '-createdAt' ] | 27 | VIDEOS: [ 'name', '-name', 'duration', '-duration', 'createdAt', '-createdAt', 'views', '-views' ] |
28 | } | 28 | } |
29 | 29 | ||
30 | const OAUTH_LIFETIME = { | 30 | const OAUTH_LIFETIME = { |
@@ -116,11 +116,16 @@ const REQUESTS_LIMIT_PODS = 10 | |||
116 | // How many requests we send to a pod per interval | 116 | // How many requests we send to a pod per interval |
117 | const REQUESTS_LIMIT_PER_POD = 5 | 117 | const REQUESTS_LIMIT_PER_POD = 5 |
118 | 118 | ||
119 | const REQUESTS_VIDEO_QADU_LIMIT_PODS = 10 | ||
120 | // The QADU requests are not big | ||
121 | const REQUESTS_VIDEO_QADU_LIMIT_PER_POD = 50 | ||
122 | |||
119 | // Number of requests to retry for replay requests module | 123 | // Number of requests to retry for replay requests module |
120 | const RETRY_REQUESTS = 5 | 124 | const RETRY_REQUESTS = 5 |
121 | 125 | ||
122 | const REQUEST_ENDPOINTS = { | 126 | const REQUEST_ENDPOINTS = { |
123 | VIDEOS: 'videos' | 127 | VIDEOS: 'videos', |
128 | QADU: 'videos/qadu' | ||
124 | } | 129 | } |
125 | const REQUEST_ENDPOINT_ACTIONS = {} | 130 | const REQUEST_ENDPOINT_ACTIONS = {} |
126 | REQUEST_ENDPOINT_ACTIONS[REQUEST_ENDPOINTS.VIDEOS] = { | 131 | REQUEST_ENDPOINT_ACTIONS[REQUEST_ENDPOINTS.VIDEOS] = { |
@@ -130,6 +135,12 @@ REQUEST_ENDPOINT_ACTIONS[REQUEST_ENDPOINTS.VIDEOS] = { | |||
130 | REPORT_ABUSE: 'report-abuse' | 135 | REPORT_ABUSE: 'report-abuse' |
131 | } | 136 | } |
132 | 137 | ||
138 | const REQUEST_VIDEO_QADU_TYPES = { | ||
139 | LIKES: 'likes', | ||
140 | DISLIKES: 'dislikes', | ||
141 | VIEWS: 'views' | ||
142 | } | ||
143 | |||
133 | const REMOTE_SCHEME = { | 144 | const REMOTE_SCHEME = { |
134 | HTTP: 'https', | 145 | HTTP: 'https', |
135 | WS: 'wss' | 146 | WS: 'wss' |
@@ -199,10 +210,13 @@ module.exports = { | |||
199 | REMOTE_SCHEME, | 210 | REMOTE_SCHEME, |
200 | REQUEST_ENDPOINT_ACTIONS, | 211 | REQUEST_ENDPOINT_ACTIONS, |
201 | REQUEST_ENDPOINTS, | 212 | REQUEST_ENDPOINTS, |
213 | REQUEST_VIDEO_QADU_TYPES, | ||
202 | REQUESTS_IN_PARALLEL, | 214 | REQUESTS_IN_PARALLEL, |
203 | REQUESTS_INTERVAL, | 215 | REQUESTS_INTERVAL, |
204 | REQUESTS_LIMIT_PER_POD, | 216 | REQUESTS_LIMIT_PER_POD, |
205 | REQUESTS_LIMIT_PODS, | 217 | REQUESTS_LIMIT_PODS, |
218 | REQUESTS_VIDEO_QADU_LIMIT_PER_POD, | ||
219 | REQUESTS_VIDEO_QADU_LIMIT_PODS, | ||
206 | RETRY_REQUESTS, | 220 | RETRY_REQUESTS, |
207 | SEARCHABLE_COLUMNS, | 221 | SEARCHABLE_COLUMNS, |
208 | SIGNATURE_ALGORITHM, | 222 | SIGNATURE_ALGORITHM, |
diff --git a/server/initializers/migrations/0015-video-views.js b/server/initializers/migrations/0015-video-views.js new file mode 100644 index 000000000..ae49fe73c --- /dev/null +++ b/server/initializers/migrations/0015-video-views.js | |||
@@ -0,0 +1,19 @@ | |||
1 | 'use strict' | ||
2 | |||
3 | // utils = { transaction, queryInterface, sequelize, Sequelize } | ||
4 | exports.up = function (utils, finalCallback) { | ||
5 | const q = utils.queryInterface | ||
6 | const Sequelize = utils.Sequelize | ||
7 | |||
8 | const data = { | ||
9 | type: Sequelize.INTEGER, | ||
10 | allowNull: false, | ||
11 | defaultValue: 0 | ||
12 | } | ||
13 | |||
14 | q.addColumn('Videos', 'views', data, { transaction: utils.transaction }).asCallback(finalCallback) | ||
15 | } | ||
16 | |||
17 | exports.down = function (options, callback) { | ||
18 | throw new Error('Not implemented.') | ||
19 | } | ||