diff options
author | Chocobozzz <me@florianbigard.com> | 2022-03-24 13:36:47 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2022-04-15 09:49:35 +0200 |
commit | b211106695bb82f6c32e53306081b5262c3d109d (patch) | |
tree | fa187de1c33b0956665f5362e29af6b0f6d8bb57 /server/initializers/constants.ts | |
parent | 69d48ee30c9d47cddf0c3c047dc99a99dcb6e894 (diff) | |
download | PeerTube-b211106695bb82f6c32e53306081b5262c3d109d.tar.gz PeerTube-b211106695bb82f6c32e53306081b5262c3d109d.tar.zst PeerTube-b211106695bb82f6c32e53306081b5262c3d109d.zip |
Support video views/viewers stats in server
* Add "currentTime" and "event" body params to view endpoint
* Merge watching and view endpoints
* Introduce WatchAction AP activity
* Add tables to store viewer information of local videos
* Add endpoints to fetch video views/viewers stats of local videos
* Refactor views/viewers handlers
* Support "views" and "viewers" counters for both VOD and live videos
Diffstat (limited to 'server/initializers/constants.ts')
-rw-r--r-- | server/initializers/constants.ts | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 6bcefe0db..4929923dc 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -24,7 +24,7 @@ import { CONFIG, registerConfigChangedHandler } from './config' | |||
24 | 24 | ||
25 | // --------------------------------------------------------------------------- | 25 | // --------------------------------------------------------------------------- |
26 | 26 | ||
27 | const LAST_MIGRATION_VERSION = 700 | 27 | const LAST_MIGRATION_VERSION = 705 |
28 | 28 | ||
29 | // --------------------------------------------------------------------------- | 29 | // --------------------------------------------------------------------------- |
30 | 30 | ||
@@ -228,6 +228,7 @@ const SCHEDULER_INTERVALS_MS = { | |||
228 | REMOVE_OLD_JOBS: 60000 * 60, // 1 hour | 228 | REMOVE_OLD_JOBS: 60000 * 60, // 1 hour |
229 | UPDATE_VIDEOS: 60000, // 1 minute | 229 | UPDATE_VIDEOS: 60000, // 1 minute |
230 | YOUTUBE_DL_UPDATE: 60000 * 60 * 24, // 1 day | 230 | YOUTUBE_DL_UPDATE: 60000 * 60 * 24, // 1 day |
231 | GEO_IP_UPDATE: 60000 * 60 * 24, // 1 day | ||
231 | VIDEO_VIEWS_BUFFER_UPDATE: CONFIG.VIEWS.VIDEOS.LOCAL_BUFFER_UPDATE_INTERVAL, | 232 | VIDEO_VIEWS_BUFFER_UPDATE: CONFIG.VIEWS.VIDEOS.LOCAL_BUFFER_UPDATE_INTERVAL, |
232 | CHECK_PLUGINS: CONFIG.PLUGINS.INDEX.CHECK_LATEST_VERSIONS_INTERVAL, | 233 | CHECK_PLUGINS: CONFIG.PLUGINS.INDEX.CHECK_LATEST_VERSIONS_INTERVAL, |
233 | CHECK_PEERTUBE_VERSION: 60000 * 60 * 24, // 1 day | 234 | CHECK_PEERTUBE_VERSION: 60000 * 60 * 24, // 1 day |
@@ -366,9 +367,12 @@ const CONSTRAINTS_FIELDS = { | |||
366 | 367 | ||
367 | const VIEW_LIFETIME = { | 368 | const VIEW_LIFETIME = { |
368 | VIEW: CONFIG.VIEWS.VIDEOS.IP_VIEW_EXPIRATION, | 369 | VIEW: CONFIG.VIEWS.VIDEOS.IP_VIEW_EXPIRATION, |
369 | VIEWER: 60000 * 5 // 5 minutes | 370 | VIEWER: 60000 * 5, // 5 minutes |
371 | VIEWER_STATS: 60000 * 60 // 1 hour | ||
370 | } | 372 | } |
371 | 373 | ||
374 | const MAX_LOCAL_VIEWER_WATCH_SECTIONS = 10 | ||
375 | |||
372 | let CONTACT_FORM_LIFETIME = 60000 * 60 // 1 hour | 376 | let CONTACT_FORM_LIFETIME = 60000 * 60 // 1 hour |
373 | 377 | ||
374 | const VIDEO_TRANSCODING_FPS: VideoTranscodingFPS = { | 378 | const VIDEO_TRANSCODING_FPS: VideoTranscodingFPS = { |
@@ -800,6 +804,12 @@ const SEARCH_INDEX = { | |||
800 | 804 | ||
801 | // --------------------------------------------------------------------------- | 805 | // --------------------------------------------------------------------------- |
802 | 806 | ||
807 | const STATS_TIMESERIE = { | ||
808 | MAX_DAYS: 30 | ||
809 | } | ||
810 | |||
811 | // --------------------------------------------------------------------------- | ||
812 | |||
803 | // Special constants for a test instance | 813 | // Special constants for a test instance |
804 | if (isTestInstance() === true) { | 814 | if (isTestInstance() === true) { |
805 | PRIVATE_RSA_KEY_SIZE = 1024 | 815 | PRIVATE_RSA_KEY_SIZE = 1024 |
@@ -836,6 +846,7 @@ if (isTestInstance() === true) { | |||
836 | REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1 | 846 | REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1 |
837 | 847 | ||
838 | VIEW_LIFETIME.VIEWER = 1000 * 5 // 5 second | 848 | VIEW_LIFETIME.VIEWER = 1000 * 5 // 5 second |
849 | VIEW_LIFETIME.VIEWER_STATS = 1000 * 5 // 5 second | ||
839 | CONTACT_FORM_LIFETIME = 1000 // 1 second | 850 | CONTACT_FORM_LIFETIME = 1000 // 1 second |
840 | 851 | ||
841 | JOB_ATTEMPTS['email'] = 1 | 852 | JOB_ATTEMPTS['email'] = 1 |
@@ -907,6 +918,7 @@ export { | |||
907 | LAST_MIGRATION_VERSION, | 918 | LAST_MIGRATION_VERSION, |
908 | OAUTH_LIFETIME, | 919 | OAUTH_LIFETIME, |
909 | CUSTOM_HTML_TAG_COMMENTS, | 920 | CUSTOM_HTML_TAG_COMMENTS, |
921 | STATS_TIMESERIE, | ||
910 | BROADCAST_CONCURRENCY, | 922 | BROADCAST_CONCURRENCY, |
911 | AUDIT_LOG_FILENAME, | 923 | AUDIT_LOG_FILENAME, |
912 | PAGINATION, | 924 | PAGINATION, |
@@ -949,6 +961,7 @@ export { | |||
949 | ABUSE_STATES, | 961 | ABUSE_STATES, |
950 | LRU_CACHE, | 962 | LRU_CACHE, |
951 | REQUEST_TIMEOUTS, | 963 | REQUEST_TIMEOUTS, |
964 | MAX_LOCAL_VIEWER_WATCH_SECTIONS, | ||
952 | USER_PASSWORD_RESET_LIFETIME, | 965 | USER_PASSWORD_RESET_LIFETIME, |
953 | USER_PASSWORD_CREATE_LIFETIME, | 966 | USER_PASSWORD_CREATE_LIFETIME, |
954 | MEMOIZE_TTL, | 967 | MEMOIZE_TTL, |