aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/database.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-03-24 13:36:47 +0100
committerChocobozzz <chocobozzz@cpy.re>2022-04-15 09:49:35 +0200
commitb211106695bb82f6c32e53306081b5262c3d109d (patch)
treefa187de1c33b0956665f5362e29af6b0f6d8bb57 /server/initializers/database.ts
parent69d48ee30c9d47cddf0c3c047dc99a99dcb6e894 (diff)
downloadPeerTube-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/database.ts')
-rw-r--r--server/initializers/database.ts10
1 files changed, 7 insertions, 3 deletions
diff --git a/server/initializers/database.ts b/server/initializers/database.ts
index 0e690f6ae..7a7ba61f4 100644
--- a/server/initializers/database.ts
+++ b/server/initializers/database.ts
@@ -1,10 +1,14 @@
1import { QueryTypes, Transaction } from 'sequelize' 1import { QueryTypes, Transaction } from 'sequelize'
2import { Sequelize as SequelizeTypescript } from 'sequelize-typescript' 2import { Sequelize as SequelizeTypescript } from 'sequelize-typescript'
3import { ActorCustomPageModel } from '@server/models/account/actor-custom-page'
3import { TrackerModel } from '@server/models/server/tracker' 4import { TrackerModel } from '@server/models/server/tracker'
4import { VideoTrackerModel } from '@server/models/server/video-tracker' 5import { VideoTrackerModel } from '@server/models/server/video-tracker'
5import { UserModel } from '@server/models/user/user' 6import { UserModel } from '@server/models/user/user'
6import { UserNotificationModel } from '@server/models/user/user-notification' 7import { UserNotificationModel } from '@server/models/user/user-notification'
7import { UserVideoHistoryModel } from '@server/models/user/user-video-history' 8import { UserVideoHistoryModel } from '@server/models/user/user-video-history'
9import { VideoJobInfoModel } from '@server/models/video/video-job-info'
10import { LocalVideoViewerModel } from '@server/models/view/local-video-viewer'
11import { LocalVideoViewerWatchSectionModel } from '@server/models/view/local-video-viewer-watch-section'
8import { isTestInstance } from '../helpers/core-utils' 12import { isTestInstance } from '../helpers/core-utils'
9import { logger } from '../helpers/logger' 13import { logger } from '../helpers/logger'
10import { AbuseModel } from '../models/abuse/abuse' 14import { AbuseModel } from '../models/abuse/abuse'
@@ -42,10 +46,8 @@ import { VideoPlaylistElementModel } from '../models/video/video-playlist-elemen
42import { VideoShareModel } from '../models/video/video-share' 46import { VideoShareModel } from '../models/video/video-share'
43import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' 47import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist'
44import { VideoTagModel } from '../models/video/video-tag' 48import { VideoTagModel } from '../models/video/video-tag'
45import { VideoViewModel } from '../models/video/video-view' 49import { VideoViewModel } from '../models/view/video-view'
46import { CONFIG } from './config' 50import { CONFIG } from './config'
47import { ActorCustomPageModel } from '@server/models/account/actor-custom-page'
48import { VideoJobInfoModel } from '@server/models/video/video-job-info'
49 51
50require('pg').defaults.parseInt8 = true // Avoid BIGINT to be converted to string 52require('pg').defaults.parseInt8 = true // Avoid BIGINT to be converted to string
51 53
@@ -140,6 +142,8 @@ async function initDatabaseModels (silent: boolean) {
140 VideoStreamingPlaylistModel, 142 VideoStreamingPlaylistModel,
141 VideoPlaylistModel, 143 VideoPlaylistModel,
142 VideoPlaylistElementModel, 144 VideoPlaylistElementModel,
145 LocalVideoViewerModel,
146 LocalVideoViewerWatchSectionModel,
143 ThumbnailModel, 147 ThumbnailModel,
144 TrackerModel, 148 TrackerModel,
145 VideoTrackerModel, 149 VideoTrackerModel,