]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/initializers/constants.js
Allow to sort by likes
[github/Chocobozzz/PeerTube.git] / server / initializers / constants.js
index 8215808931aa19fba67bf14e6b41b903145e464d..f9247e9450cab909e9b85669e83ccc2df54c69ea 100644 (file)
@@ -5,7 +5,7 @@ const path = require('path')
 
 // ---------------------------------------------------------------------------
 
-const LAST_MIGRATION_VERSION = 10
+const LAST_MIGRATION_VERSION = 25
 
 // ---------------------------------------------------------------------------
 
@@ -22,9 +22,9 @@ const SEARCHABLE_COLUMNS = {
 
 // Sortable columns per schema
 const SORTABLE_COLUMNS = {
-  USERS: [ 'id', '-id', 'username', '-username', 'createdAt', '-createdAt' ],
-  VIDEO_ABUSES: [ 'id', '-id', 'createdAt', '-createdAt' ],
-  VIDEOS: [ 'name', '-name', 'duration', '-duration', 'createdAt', '-createdAt' ]
+  USERS: [ 'id', 'username', 'createdAt' ],
+  VIDEO_ABUSES: [ 'id', 'createdAt' ],
+  VIDEOS: [ 'name', 'duration', 'createdAt', 'views', 'likes' ]
 }
 
 const OAUTH_LIFETIME = {
@@ -85,10 +85,21 @@ const CONSTRAINTS_FIELDS = {
     TAGS: { min: 1, max: 3 }, // Number of total tags
     TAG: { min: 2, max: 10 }, // Length
     THUMBNAIL: { min: 2, max: 30 },
-    THUMBNAIL_DATA: { min: 0, max: 20000 } // Bytes
+    THUMBNAIL_DATA: { min: 0, max: 20000 }, // Bytes
+    VIEWS: { min: 0 },
+    LIKES: { min: 0 },
+    DISLIKES: { min: 0 }
+  },
+  VIDEO_EVENTS: {
+    COUNT: { min: 0 }
   }
 }
 
+const VIDEO_RATE_TYPES = {
+  LIKE: 'like',
+  DISLIKE: 'dislike'
+}
+
 // ---------------------------------------------------------------------------
 
 // Score a pod has when we create it as a friend
@@ -116,12 +127,21 @@ const REQUESTS_LIMIT_PODS = 10
 // How many requests we send to a pod per interval
 const REQUESTS_LIMIT_PER_POD = 5
 
+const REQUESTS_VIDEO_QADU_LIMIT_PODS = 10
+// The QADU requests are not big
+const REQUESTS_VIDEO_QADU_LIMIT_PER_POD = 50
+
+const REQUESTS_VIDEO_EVENT_LIMIT_PODS = 10
+// The EVENTS requests are not big
+const REQUESTS_VIDEO_EVENT_LIMIT_PER_POD = 50
+
 // Number of requests to retry for replay requests module
 const RETRY_REQUESTS = 5
 
 const REQUEST_ENDPOINTS = {
   VIDEOS: 'videos'
 }
+
 const REQUEST_ENDPOINT_ACTIONS = {}
 REQUEST_ENDPOINT_ACTIONS[REQUEST_ENDPOINTS.VIDEOS] = {
   ADD: 'add',
@@ -130,6 +150,21 @@ REQUEST_ENDPOINT_ACTIONS[REQUEST_ENDPOINTS.VIDEOS] = {
   REPORT_ABUSE: 'report-abuse'
 }
 
+const REQUEST_VIDEO_QADU_ENDPOINT = 'videos/qadu'
+const REQUEST_VIDEO_EVENT_ENDPOINT = 'videos/events'
+
+const REQUEST_VIDEO_QADU_TYPES = {
+  LIKES: 'likes',
+  DISLIKES: 'dislikes',
+  VIEWS: 'views'
+}
+
+const REQUEST_VIDEO_EVENT_TYPES = {
+  LIKES: 'likes',
+  DISLIKES: 'dislikes',
+  VIEWS: 'views'
+}
+
 const REMOTE_SCHEME = {
   HTTP: 'https',
   WS: 'wss'
@@ -199,10 +234,18 @@ module.exports = {
   REMOTE_SCHEME,
   REQUEST_ENDPOINT_ACTIONS,
   REQUEST_ENDPOINTS,
+  REQUEST_VIDEO_EVENT_ENDPOINT,
+  REQUEST_VIDEO_EVENT_TYPES,
+  REQUEST_VIDEO_QADU_ENDPOINT,
+  REQUEST_VIDEO_QADU_TYPES,
   REQUESTS_IN_PARALLEL,
   REQUESTS_INTERVAL,
   REQUESTS_LIMIT_PER_POD,
   REQUESTS_LIMIT_PODS,
+  REQUESTS_VIDEO_EVENT_LIMIT_PER_POD,
+  REQUESTS_VIDEO_EVENT_LIMIT_PODS,
+  REQUESTS_VIDEO_QADU_LIMIT_PER_POD,
+  REQUESTS_VIDEO_QADU_LIMIT_PODS,
   RETRY_REQUESTS,
   SEARCHABLE_COLUMNS,
   SIGNATURE_ALGORITHM,
@@ -211,7 +254,8 @@ module.exports = {
   STATIC_MAX_AGE,
   STATIC_PATHS,
   THUMBNAILS_SIZE,
-  USER_ROLES
+  USER_ROLES,
+  VIDEO_RATE_TYPES
 }
 
 // ---------------------------------------------------------------------------